//function $(selector) {
//    return {
//        dom: dom(selector),
//        on: on,
//        offset: offset,
//        height: height,
//        text: text,
//        css: css,
//        append: append,
//        setData: setData,
//        value: value
//    };
//}

//var bScrollMouseUp = false;
/* window.addEventListener('DOMMouseScroll', function(e) {
    if (e.detail < 0) {
        bScrollMouseUp = false;
    } else {
        bScrollMouseUp = true;
    }
})

window.addEventListener('mousewheel', function(e) {
    if (e.wheelDelta < 0) {
        bScrollMouseUp = false;
    } else {
        bScrollMouseUp = true;
    }
})

window.addEventListener('click', function(e) {
    bScrollMouseUp = false;
}) */

function scrollviewtable(name, arrHeader, rowHeight, PREBUFFER, Options) {
	if (PREBUFFER == undefined) {
		PREBUFFER = 5;
	}
	$('#' + name)[0].addEventListener('contextmenu', function(e) {
		self.event.returnValue = false;
	});
	if (Options == undefined) {
		Options = {};
	}
	var iScrollbarWidth = 0; // getScrollbarWidth();
	//if (iScrollbarWidth < 5) {
	//    iScrollbarWidth = 15;
	//}
	var dataBuffer = [];
	var dataViewBuffer = [];
	var arrBufferDomainActual = new Array();
	var bPaging = false; //是否分页
	var iPagingCount = 500000; //分页数500000
	var iPagingIndex = 1; //当前页
	var divFrozenBufferView = undefined;
	var bFrozen = false;
	var that = this;
	var sMoreHeader = "";
	var sSearchFilter = "";
	var sSortFilter = "";
	var sHideColumn = "";
	var bMoreSearch = false;
	var arrSearchData = [];
	var bSearchData = false;
	var iSearchdisableCount = 0;
	var arrMergeWait = [];
	var sBtnOk = "确定";
	var sBtnCancel = "取消";
	var iClickMobile = 0;
	var arrShowTrue = [];
	var bGlobalSetData = true;
	var bStartSearch = false;
	var arrBufferKeyIndex = [];

	if (Options["btnOk"]) {
		sBtnOk = Options["btnOk"];
	}
	if (Options["btnCancel"]) {
		sBtnCancel = Options["btnCancel"];
	}
	for (var i = 0; i < arrHeader.length; i++) {
		if (arrHeader[i].search) {
			bMoreSearch = true;
			sSearchFilter += '<input type="text" id="' + name + "_search_" + arrHeader[i].field + '" name="' + arrHeader[i].field +
				'" text="' + formatter(arrHeader[i].searchText) +
				'" style="width:170px; height: 25px; margin-left: 3px;margin-bottom: 2px;" placeholder="' + arrHeader[i].title +
				'" /><br />'
		}
	}
	if (bMoreSearch) {
		sMoreHeader = '<div id="' + name +
			'_more_searchbtn" style="width: 16px; height: 16px; float: left; margin-top: 7px; margin-left: 7px;" class="more_search"></div>';
		sSearchFilter += '<input type="button" id="' + name + '_search_ok" value="' + sBtnOk +
			'" style="margin-left: 3px;" />&nbsp;&nbsp;<input type="button" id="' + name + '_search_cancel" value="' +
			sBtnCancel + '" />';

	}
	if (Options["excel"]) {
		sMoreHeader = sMoreHeader + '<div id="' + name +
			'_more_excel" style="width: 16px; height: 16px; float: left; margin-top: 7px; margin-left: 7px;" class="more_excel"></div>';
	}
	if (Options["sortcolumn"]) {
		sMoreHeader = sMoreHeader + '<div id="' + name +
			'_more_sortcolumn" style="width: 16px; height: 16px; float: left; margin-top: 7px; margin-left: 7px;" class="more_sortcolumn"></div>';
		sSortFilter = "<select id=\"" + name +
			"_more_sort_list\" style=\"width:160px;height: 125px;padding: 3px;\" multiple></select><input id=\"" + name +
			"_more_up\" type=\"button\" style=\"width: 30px; float:right; margin-right: 5px; margin-top: 35px;\" value=\"↑\"></input><input id=\"" +
			name +
			"_more_down\" style=\"width: 30px; float:right; margin-right: 5px; margin-top: -55px;\" type=\"button\" value=\"↓\"></input>";
		sSortFilter += '<div style="height:6px;"></div><input type="button" id="' + name + '_sort_ok" value="' + sBtnOk +
			'" style="margin-left: 3px;" />&nbsp;&nbsp;<input type="button" id="' + name + '_sort_cancel" value="' + sBtnCancel +
			'" />';
	}
	if (Options["hidecolumn"]) {
		sMoreHeader = sMoreHeader + '<div id="' + name +
			'_more_hidecolumn" style="width: 16px; height: 16px; float: left; margin-top: 7px; margin-left: 7px;" class="more_hidecolumn"></div>';
		sHideColumn = "<div id=\"" + name + "_more_hidecolumn_chk\" style=\"width:95%; height: 125px;overflow-x:auto;\">";
		$.each(arrHeader, function(iH, valueH) {
			var sHideColumnChk = "<input type=\"checkbox\" " + ((valueH["hide"] || valueH["width"] == 0) ? "" : "checked") +
				" value=\"" + valueH["field"] + "_" + valueH["title"] + "\"></input>" + valueH["title"];
			sHideColumn = sHideColumn + sHideColumnChk + "<br />";
		});
		sHideColumn = sHideColumn + "</div>";
		sHideColumn += '<div style="height:6px;"></div><input type="button" id="' + name + '_hidecolumn_ok" value="' + sBtnOk +
			'" style="margin-left: 3px;" />&nbsp;&nbsp;<input type="button" id="' + name + '_hidecolumn_cancel" value="' +
			sBtnCancel + '" />';
	}
	sMoreHeader = sMoreHeader + "<br /><hr />";

	var scrolltable = {
		dom: dom('#' + name),
		on: on,
		offset: offset,
		height: height,
		text: text,
		css: css,
		append: append,
		appendUpdate: appendUpdate,
		setData: iniData,
		value: value,
		scrollToIndex: scrollToIndex,
		updateHeight: updateHeight,
		setRow: setRow,
		delRow: delRow,
		getData: getData,
		getIndex: getIndex,
		viewReSize: viewReSize,
		merge: merge,
		unmerge: unmerge,
		search: SetSearch
	};
	scrolltable.dom.innerHTML = "";
	$('#' + name).append('<div style="display:none;"  class="moreopen" id="' + name + '_more"></div >');

	var iClickIndex = name + "1_1_234241412313131313131";
	scrolltable.SelectByID = function(selector) {
		return scrolltable.Select('#' + name + "_" + selector);
	}

	scrolltable.Select = function(selector) {
		return {
			dom: dom(selector),
			on: on,
			offset: offset,
			height: height,
			text: text,
			css: css,
			append: append,
			appendUpdate: appendUpdate,
			setData: iniData,
			value: value,
			scrollToIndex: scrollToIndex,
			updateHeight: updateHeight,
			setRow: setRow,
			delRow: delRow,
			getData: getData,
			getIndex: getIndex,
			search: SetSearch
		}
	}

	scrolltable.log = function() {
		console.log.apply(console, arguments);
	};

	scrolltable.nearestModulo = function(num, module) {
		var val = num % module;
		if (val === 0) {
			return num;
		}

		return val < module / 2 ? num - val : num + (module - val);
	}

	function viewReSize() {
		setTimeout(function() {
			document.getElementById(name + '_Scroller').style.top = (scrolltable.dom.offsetHeight - 20) + 'px';
			document.getElementById(name + '_BufferAllView').height = (scrolltable.dom.offsetHeight - rowHeight) + 'px';
			if (Options["hideHeader"]) {
				document.getElementById(name + '_BufferAllView').style.height = (scrolltable.dom.offsetHeight) + 'px';
			}
			updateHeight();
			if (!Options["isMobile"]) {
				$('#' + name + '_Scroller').niceScroll().resize();
				$('#' + name + '_BufferContainer').niceScroll({
					horizrailenabled: false
				}).resize();
			}
		}, 1000);
	}

	function merge(index, arrMerge) {
		arrMergeWait.push({
			"index": index,
			"arrMerge": arrMerge,
			"isMerge": true
		});
		/* setTimeout(function(){
			//merge(1,[{"c": 第几列, "cl": 合并多少列, "r": 合并多少行}]])
			dataBuffer[index]["merge"] = arrMerge;
		}, 500); */
	}

	function unmerge(index, arrMerge) {
		arrMergeWait.push({
			"index": index,
			"arrMerge": arrMerge,
			"isMerge": false
		});
		/* setTimeout(function(){
			dataBuffer[index]["merge"] = undefined;
		}, 500); */
	}

	EleResize.on(document.getElementById(name), viewReSize);

	function formatter(row, value) {
		if (value == undefined) {
			return "";
		}
		return value.toString();
	}


	function SortData(index, doType) {
		iPagingIndex = 1;
		iniData(QuickSort(dataBuffer, index, doType));
	}

	function createHeader() {
		var bHasHeader = false;
		if ($('#' + name + "_Header").length > 0) {
			bHasHeader = true;
			$('#' + name + "_Header").empty();
		}
		if ($('#' + name + "_Frozen_Header").length > 0) {
			bHasHeader = true;
			$('#' + name + "_Frozen_Header").empty();
		}
		var iHeight = 0;
		if (arrHeader.length > 0) {
			iHeight = rowHeight;
		}
		var docFrag = document.createDocumentFragment();
		if (bHasHeader) {
			docFrag = $('#' + name + "_Header")[0];
		}
		var ele = document.createElement('div');
		ele.style.height = iHeight + "px";
		ele.style.lineHeight = iHeight + "px";
		ele.style.display = "inline-block";
		ele.style.whiteSpace = "nowrap";
		ele.style.position = "relative";
		ele.style.left = '0px';
		ele.style.top = '0px';
		ele.classList.add("viewheaders");
		ele.id = name + "_Header";
		docFrag.appendChild(ele);
		bFrozen = false;
		var bAddMore = false;
		for (var i = 0; i < arrHeader.length; i++) {
			if (arrHeader[i]["formatter"] == undefined) {
				arrHeader[i]["formatter"] = formatter;
			}
			if (arrHeader[i]["headerformatter"] == undefined) {
				arrHeader[i]["headerformatter"] = formatter;
			}
			if (arrHeader[i].iskey) {
				sKey = arrHeader[i].field;
			}
			if (arrHeader[i]["hide"]) {
				arrHeader[i].width = 0;
				continue;
			}
			if (Options["isMobile"]) {
				arrHeader[i]["frozen"] = false;
			}
			if (arrHeader[i]["frozen"]) {
				bFrozen = true;
			}
			var eleChild = document.createElement('div');
			eleChild.style.width = arrHeader[i].width + "px";
			eleChild.innerHTML = arrHeader[i]["headerformatter"](arrHeader[i], arrHeader[i].title);
			eleChild.innerHTML = arrHeader[i]["headerformatter"](arrHeader[i], arrHeader[i].title);
			if (arrHeader[i].sort) {
				eleChild.innerHTML = '<span>' + arrHeader[i].title + '</span>' +
					'<span style="float:right; margin-top: 8px; margin-right: 10px;" class="triangle_border_up" ><span></span></span>' +
					'<span style="float:right; margin-top: 20px; margin-right: -16px;" class="triangle_border_down" ><span></span></span>';
				(function(eleT, iT) {
					$(eleT).find(".triangle_border_up")[0].addEventListener('click', function(e) {
						SortData(iT, true);
					});
					$(eleT).find(".triangle_border_down")[0].addEventListener('click', function(e) {
						SortData(iT, false);
					});
				})(eleChild, i);
			}
			if (!bAddMore && !bFrozen && sMoreHeader != "<br /><hr />") {
				eleChild.innerHTML = '<span class="more"></span >' + eleChild.innerHTML;
				$(eleChild).find(".more")[0].addEventListener('click', function(e) {
					if ($('#' + name + '_more').css("display") == 'none') {
						if (sSearchFilter.length > 0) {
							$('#' + name + '_more').html(sMoreHeader + "<div id='" + name + "_more_content'>" + sSearchFilter + "</div>");
							for (var j = 0; j < arrHeader.length; j++) {
								if (arrHeader[j].search) {
									$('#' + name + "_search_" + arrHeader[j].field).val(formatter(arrHeader[j], arrHeader[j].searchText));
								}
							}
						} else if (sSortFilter.length > 0) {
							$('#' + name + '_more').html(sMoreHeader + "<div id='" + name + "_more_content'>" + sSortFilter + "</div>");
						} else if (sHideColumn.length > 0) {
							$('#' + name + '_more').html(sMoreHeader + "<div id='" + name + "_more_content'>" + sHideColumn + "</div>");
						}
						More_Search(true);
						More_Sort(true);
						More_HideColumn(true);
						$('#' + name + '_more').show();
						if ($("#" + name + "_more_excel").length > 0) {
							$("#" + name + "_more_excel")[0].addEventListener('click', function(e) {
								$('#' + name + "_more").hide();
								var dataExcel = {
									"header": [],
									"rows": [],
									"excelStr": ""
								};
								var arrHttpMap = [];
								$.each(arrHeader, function(iH, valueH) {
									if (valueH["width"] == 0) {

									} else {
										dataExcel.header.push(valueH);
									}
								});
								dataExcel.excelStr =
									'<?xml version="1.0" encoding="utf-8"?><?mso-application progid="Excel.Sheet"?><ss:Workbook xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:o="urn:schemas-microsoft-com:office:office"  xmlns:html="http://www.w3.org/TR/REC-html40"><DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"><Title>' +
									Options["excel"].title +
									'</Title><Version>15.00</Version></DocumentProperties><ss:ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"><ss:WindowHeight>9000</ss:WindowHeight><ss:WindowWidth>43850</ss:WindowWidth><ss:ProtectStructure>False</ss:ProtectStructure><ss:ProtectWindows>False</ss:ProtectWindows></ss:ExcelWorkbook><ss:Styles><ss:Style ss:ID="Default"><ss:Alignment ss:Vertical="Top"  /><ss:Font ss:FontName="arial" ss:Size="10" /><ss:Borders><ss:Border  ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Top" /><ss:Border  ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Bottom" /><ss:Border  ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Left" /><ss:Border ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Right" /></ss:Borders><ss:Interior /><ss:NumberFormat /><ss:Protection /></ss:Style><ss:Style ss:ID="title"><ss:Borders /><ss:Font /><ss:Alignment  ss:Vertical="Center" ss:Horizontal="Center" /><ss:NumberFormat ss:Format="@" /></ss:Style><ss:Style ss:ID="headercell"><ss:Font ss:Bold="1" ss:Size="10" /><ss:Alignment  ss:Horizontal="Center" /><ss:Interior ss:Pattern="Solid"  /></ss:Style><ss:Style ss:ID="even"><ss:Interior ss:Pattern="Solid"  /></ss:Style><ss:Style ss:Parent="even" ss:ID="evendate"><ss:NumberFormat ss:Format="yyyy-mm-dd" /></ss:Style><ss:Style ss:Parent="even" ss:ID="evenint"><ss:NumberFormat ss:Format="0" /></ss:Style><ss:Style ss:Parent="even" ss:ID="evenfloat"><ss:NumberFormat ss:Format="0.00" /></ss:Style><ss:Style ss:ID="odd"><ss:Interior ss:Pattern="Solid"  /></ss:Style><ss:Style ss:Parent="odd" ss:ID="odddate"><ss:NumberFormat ss:Format="yyyy-mm-dd" /></ss:Style><ss:Style ss:Parent="odd" ss:ID="oddint"><ss:NumberFormat ss:Format="0" /></ss:Style><ss:Style ss:Parent="odd" ss:ID="oddfloat"><ss:NumberFormat ss:Format="0.00" /></ss:Style></ss:Styles><ss:Worksheet ss:Name="' +
									Options["excel"].title + '"><ss:Names><ss:NamedRange ss:Name="Print_Titles" ss:RefersTo="=\'' + Options[
										"excel"].title + '\'!R1:R2" /></ss:Names>';
								if (dataExcel.header.length > 0) {
									$.each(dataBuffer, function(iB, valueB) {
										if (!valueB["searchdisable"]) {
											var rowD = {};
											$.each(dataExcel.header, function(iH, valueH) {
												rowD[valueH.field] = valueB[valueH.field];
											});
											arrHttpMap.push({
												"formula": formatter(valueB["formula"]),
												"href": formatter(valueB["href"]),
												"arrMerge": valueB["arrMerge"]
											});
											dataExcel.rows.push(rowD);
										}
									});
								}
								dataExcel.excelStr += '<ss:Table x:FullRows="1" x:FullColumns="1" ss:ExpandedColumnCount="' + (dataExcel.header
									.length + 2).toString() + '" ss:ExpandedRowCount="' + (dataExcel.rows.length + 2).toString() + '">';
								$.each(dataExcel.header, function(iH, valueH) {
									dataExcel.excelStr += '<ss:Column ss:AutoFitWidth="1" ss:Width="' + valueH.width.toString() + '" />';
								});
								dataExcel.excelStr += '<ss:Row ss:AutoFitHeight="1">';
								$.each(dataExcel.header, function(iH, valueH) {
									dataExcel.excelStr += '<ss:Cell ss:StyleID="headercell"><ss:Data ss:Type="String">' + valueH.title +
										'</ss:Data><ss:NamedCell ss:Name="Print_Titles" /></ss:Cell>';
								});
								dataExcel.excelStr += '</ss:Row>';
								if (dataExcel.rows.length > 0) {
									$.each(dataExcel.rows, function(iR, valueR) {
										if (valueR["searchdisable"]) {
											return true;
										}
										dataExcel.excelStr += '<ss:Row>';
										$.each(dataExcel.header, function(iH, valueH) {
											var sTextT = "";
											if (valueR[valueH.field] instanceof Date) {
												sTextT = valueR[valueH.field].getFullYear().toString() + "-" + (valueR[valueH.field].getMonth() + 1)
													.toString() + "-" + valueR[valueH.field].getDate().toString() + " " + valueR[valueH.field].getHours()
													.toString() + ":" + valueR[valueH.field].getMinutes().toString() + ":" + valueR[valueH.field].getSeconds()
													.toString()
											} else {
												sTextT = valueR[valueH.field].toString();
											}
											var sUrlT = "";
											if (sTextT.length >= 6 && sTextT[0] == '=' && sTextT[1] == 'H' && sTextT[2] == 'Y' && sTextT[3] ==
												'P' && sTextT[4] == 'E' && sTextT[5] == 'R') {
												//var sFormula = "=HYPERLINK(&quot;" + sUrl + "/Htmls/TrackGoogleMap.html?lat=" + oLat + "&amp;lng=" + oLon + "&quot;,&quot;<%=Resources.Lan.ViewLoaction %>&quot;)";
												//var sHRef = sUrl + "/Htmls/TrackGoogleMap.html?lat=" + oLat + "&amp;lng=" + oLon;
												sUrlT = "ss:Formula=\"" + arrHttpMap[iR]["formula"] + "\" ss:HRef=\"" + arrHttpMap[iR]["href"] +
													"\"";
											}
											var sMerge = "";
											if (arrHttpMap[iR]["arrMerge"]) {
												$.each(arrHttpMap[iR]["arrMerge"], function(im, valueM) {
													if (valueM.c.c == (iH + 1)) {
														if (valueM.sn == 0) {
															sMerge = 'ss:MergeDown="' + (valueM.c.r - 1).toString() + '"';
														}
														sMerge += ' ss:MergeAcross="' + (valueM.c.cl - 1).toString() + '"';
													}
												});
											}
											dataExcel.excelStr += '<ss:Cell ss:Index="' + (iH + 1).toString() + '" ' + sMerge + ' ss:StyleID="' +
												(iR % 2 == 0 ? "even" : "odd") + '" ' + sUrlT + '><ss:Data ss:Type="String">' + sTextT +
												'</ss:Data></ss:Cell>';
										});
										dataExcel.excelStr += '</ss:Row>';
									});
								}
								dataExcel.excelStr +=
									'</ss:Table><x:WorksheetOptions><x:PageSetup><x:Layout x:CenterHorizontal="1" x:Orientation="Landscape" /><x:Footer x:Data="Page &P of &N" x:Margin="0.5" /><x:PageMargins x:Top="0.5" x:Right="0.5" x:Left="0.5" x:Bottom="0.8" /></x:PageSetup><x:FitToPage /><x:Print><x:PrintErrors>Blank</x:PrintErrors><x:FitWidth>1</x:FitWidth><x:FitHeight>32767</x:FitHeight><x:ValidPrinterInfo /><x:VerticalResolution>600</x:VerticalResolution></x:Print><x:Selected /><x:DoNotDisplayGridlines /><x:ProtectObjects>False</x:ProtectObjects><x:ProtectScenarios>False</x:ProtectScenarios></x:WorksheetOptions></ss:Worksheet><ss:ExcelWorkbook><ss:WindowHeight>9000</ss:WindowHeight><ss:WindowWidth>19340</ss:WindowWidth><ss:ProtectStructure>False</ss:ProtectStructure><ss:ProtectWindows>False</ss:ProtectWindows></ss:ExcelWorkbook></ss:Workbook>';
								if (Options["excel"] && Options["excel"]["exportxls"]) {
									Options["excel"]["exportxls"](dataExcel);
								}
							});
						}
					} else {
						$('#' + name + '_more').hide();
					}
				});
				bAddMore = true;
			}
			eleChild.id = ele.id + "_" + i;
			eleChild.setAttribute("col", name + i);
			eleChild.style.display = "inline-block";
			eleChild.classList.add("headercolor");
			if (i == arrHeader.length - 1) {
				eleChild.classList.add("borderRight");
				eleChild.classList.add("borderTop");
			}

			eleChild.style.height = (rowHeight) + "px";
			eleChild.style.lineHeight = (rowHeight) + "px";
			ele.appendChild(eleChild);

			BindDrag(eleChild, eleChild.id, name, i, arrHeader, UpdateScroll);
		}
		if (arrHeader.length > 0) {
			var eleChild = document.createElement('div');
			eleChild.classList.add("headercolor");
			eleChild.innerHTML = "&nbsp;";
			eleChild.style.height = (rowHeight) + "px";
			eleChild.style.lineHeight = (rowHeight) + "px";
			eleChild.id = ele.id + "_" + arrHeader.length;
			eleChild.style.display = "inline-block";
			eleChild.style.width = "100%";
			eleChild.setAttribute("col", name + arrHeader.length);
			eleChild.classList.add("borderLeft");
			eleChild.classList.add("borderTop");
			ele.appendChild(eleChild);
		}
		if (bFrozen) {
			var iFrozenWidth = 0;
			var docFragFrozen = document.createDocumentFragment();
			if (bHasHeader) {
				docFragFrozen = $('#' + name + "_Frozen_Header")[0];
			}
			var eleFrozen = document.createElement('div');
			eleFrozen.style.height = iHeight + "px";
			eleFrozen.style.lineHeight = iHeight + "px";
			eleFrozen.style.display = "inline-block";
			eleFrozen.style.whiteSpace = "nowrap";
			eleFrozen.style.position = "absolute";
			eleFrozen.style.left = '0px';
			eleFrozen.style.top = '0px';
			eleFrozen.style.zIndex = 201;
			eleFrozen.style.boxSizing = "border-box";
			eleFrozen.classList.add("viewheaders");
			eleFrozen.classList.add("borderRight");
			eleFrozen.classList.add("headercolor");
			eleFrozen.id = name + "_Frozen_Header";
			docFragFrozen.appendChild(eleFrozen);
			var bAddMore = false;
			for (var i = 0; i < arrHeader.length; i++) {
				if (arrHeader[i]["frozen"] && !arrHeader[i].hide) {
					iFrozenWidth += arrHeader[i].width;
					var eleChild = document.createElement('div');
					eleChild.style.width = arrHeader[i].width + "px";
					eleChild.classList.add("headerRow");
					eleChild.innerHTML = arrHeader[i]["headerformatter"](arrHeader[i], arrHeader[i].title);
					if (arrHeader[i].sort) {
						eleChild.innerHTML = '<span>' + arrHeader[i].title + '</span>' +
							'<span style="float:right; margin-top: 8px; margin-right: 10px;" class="triangle_border_up" ><span></span></span>' +
							'<span style="float:right; margin-top: 20px; margin-right: -16px;" class="triangle_border_down" ><span></span></span>';
						(function(eleT, iT) {
							$(eleT).find(".triangle_border_up")[0].addEventListener('click', function(e) {
								SortData(iT, true);
							});
							$(eleT).find(".triangle_border_down")[0].addEventListener('click', function(e) {
								SortData(iT, false);
							});
						})(eleChild, i);
					}
					if (!bAddMore && sMoreHeader != "<br /><hr />") {
						eleChild.innerHTML = '<span class="more"></span>' + eleChild.innerHTML;
						bAddMore = true;
						$(eleChild).find(".more")[0].addEventListener('click', function(e) {
							if ($('#' + name + '_more').css("display") == 'none') {
								if (sSearchFilter.length > 0) {
									$('#' + name + '_more').html(sMoreHeader + "<div id='" + name + "_more_content'>" + sSearchFilter + "</div>");
									for (var j = 0; j < arrHeader.length; j++) {
										if (arrHeader[j].search) {
											$('#' + name + "_search_" + arrHeader[j].field).val(formatter(arrHeader[j], arrHeader[j].searchText));
										}
									}
								} else if (sSortFilter.length > 0) {
									$('#' + name + '_more').html(sMoreHeader + "<div id='" + name + "_more_content'>" + sSortFilter + "</div>");
								} else if (sHideColumn.length > 0) {
									$('#' + name + '_more').html(sMoreHeader + "<div id='" + name + "_more_content'>" + sHideColumn + "</div>");
								}
								More_Search(true);
								More_Sort(true);
								More_HideColumn(true);
								$('#' + name + '_more').show();
								if ($("#" + name + "_more_excel").length > 0) {
									$("#" + name + "_more_excel")[0].addEventListener('click', function(e) {
										$('#' + name + "_more").hide();
										var dataExcel = {
											"header": [],
											"rows": [],
											"excelStr": ""
										};
										var arrHttpMap = [];
										$.each(arrHeader, function(iH, valueH) {
											if (valueH["width"] == 0) {

											} else {
												dataExcel.header.push(valueH);
											}
										});
										dataExcel.excelStr =
											'<?xml version="1.0" encoding="utf-8"?><?mso-application progid="Excel.Sheet"?><ss:Workbook xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:o="urn:schemas-microsoft-com:office:office"  xmlns:html="http://www.w3.org/TR/REC-html40"><DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"><Title>' +
											Options["excel"].title +
											'</Title><Version>15.00</Version></DocumentProperties><ss:ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"><ss:WindowHeight>9000</ss:WindowHeight><ss:WindowWidth>43850</ss:WindowWidth><ss:ProtectStructure>False</ss:ProtectStructure><ss:ProtectWindows>False</ss:ProtectWindows></ss:ExcelWorkbook><ss:Styles><ss:Style ss:ID="Default"><ss:Alignment ss:Vertical="Top"  /><ss:Font ss:FontName="arial" ss:Size="10" /><ss:Borders><ss:Border  ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Top" /><ss:Border  ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Bottom" /><ss:Border  ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Left" /><ss:Border ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Right" /></ss:Borders><ss:Interior /><ss:NumberFormat /><ss:Protection /></ss:Style><ss:Style ss:ID="title"><ss:Borders /><ss:Font /><ss:Alignment  ss:Vertical="Center" ss:Horizontal="Center" /><ss:NumberFormat ss:Format="@" /></ss:Style><ss:Style ss:ID="headercell"><ss:Font ss:Bold="1" ss:Size="10" /><ss:Alignment  ss:Horizontal="Center" /><ss:Interior ss:Pattern="Solid"  /></ss:Style><ss:Style ss:ID="even"><ss:Interior ss:Pattern="Solid"  /></ss:Style><ss:Style ss:Parent="even" ss:ID="evendate"><ss:NumberFormat ss:Format="yyyy-mm-dd" /></ss:Style><ss:Style ss:Parent="even" ss:ID="evenint"><ss:NumberFormat ss:Format="0" /></ss:Style><ss:Style ss:Parent="even" ss:ID="evenfloat"><ss:NumberFormat ss:Format="0.00" /></ss:Style><ss:Style ss:ID="odd"><ss:Interior ss:Pattern="Solid"  /></ss:Style><ss:Style ss:Parent="odd" ss:ID="odddate"><ss:NumberFormat ss:Format="yyyy-mm-dd" /></ss:Style><ss:Style ss:Parent="odd" ss:ID="oddint"><ss:NumberFormat ss:Format="0" /></ss:Style><ss:Style ss:Parent="odd" ss:ID="oddfloat"><ss:NumberFormat ss:Format="0.00" /></ss:Style></ss:Styles><ss:Worksheet ss:Name="' +
											Options["excel"].title + '"><ss:Names><ss:NamedRange ss:Name="Print_Titles" ss:RefersTo="=\'' + Options[
												"excel"].title + '\'!R1:R2" /></ss:Names>';
										if (dataExcel.header.length > 0) {
											$.each(dataBuffer, function(iB, valueB) {
												if (!valueB["searchdisable"]) {
													var rowD = {};
													$.each(dataExcel.header, function(iH, valueH) {
														rowD[valueH.field] = valueB[valueH.field];
													});
													arrHttpMap.push({
														"formula": formatter(valueB["formula"]),
														"href": formatter(valueB["href"]),
														"arrMerge": valueB["arrMerge"]
													});
													dataExcel.rows.push(rowD);
												}
											});
										}
										dataExcel.excelStr += '<ss:Table x:FullRows="1" x:FullColumns="1" ss:ExpandedColumnCount="' + (dataExcel.header
											.length + 2).toString() + '" ss:ExpandedRowCount="' + (dataExcel.rows.length + 2).toString() + '">';
										$.each(dataExcel.header, function(iH, valueH) {
											dataExcel.excelStr += '<ss:Column ss:AutoFitWidth="1" ss:Width="' + valueH.width.toString() + '" />';
										});
										dataExcel.excelStr += '<ss:Row ss:AutoFitHeight="1">';
										$.each(dataExcel.header, function(iH, valueH) {
											dataExcel.excelStr += '<ss:Cell ss:StyleID="headercell"><ss:Data ss:Type="String">' + valueH.title +
												'</ss:Data><ss:NamedCell ss:Name="Print_Titles" /></ss:Cell>';
										});
										dataExcel.excelStr += '</ss:Row>';
										if (dataExcel.rows.length > 0) {
											$.each(dataExcel.rows, function(iR, valueR) {
												dataExcel.excelStr += '<ss:Row>';
												$.each(dataExcel.header, function(iH, valueH) {
													var sTextT = "";
													if (valueR[valueH.field] instanceof Date) {
														sTextT = valueR[valueH.field].getFullYear().toString() + "-" + (valueR[valueH.field].getMonth() +
																1).toString() + "-" + valueR[valueH.field].getDate().toString() + " " + valueR[valueH.field].getHours()
															.toString() + ":" + valueR[valueH.field].getMinutes().toString() + ":" + valueR[valueH.field].getSeconds()
															.toString()
													} else {
														sTextT = valueR[valueH.field].toString();
													}
													var sUrlT = "";
													if (sTextT.length >= 6 && sTextT[0] == '=' && sTextT[1] == 'H' && sTextT[2] == 'Y' && sTextT[3] ==
														'P' && sTextT[4] == 'E' && sTextT[5] == 'R') {
														//var sFormula = "=HYPERLINK(&quot;" + sUrl + "/Htmls/TrackGoogleMap.html?lat=" + oLat + "&amp;lng=" + oLon + "&quot;,&quot;<%=Resources.Lan.ViewLoaction %>&quot;)";
														//var sHRef = sUrl + "/Htmls/TrackGoogleMap.html?lat=" + oLat + "&amp;lng=" + oLon;
														sUrlT = "ss:Formula=\"" + arrHttpMap[iR]["formula"] + "\" ss:HRef=\"" + arrHttpMap[iR]["href"] +
															"\"";
													}

													var sMerge = "";
													if (arrHttpMap[iR]["arrMerge"]) {
														$.each(arrHttpMap[iR]["arrMerge"], function(im, valueM) {
															if (valueM.c.c == (iH + 1)) {
																if (valueM.sn == 0) {
																	sMerge = 'ss:MergeDown="' + (valueM.c.r - 1).toString() + '"';
																}
																sMerge += ' ss:MergeAcross="' + (valueM.c.cl - 1).toString() + '"';
															}
														});
													}
													dataExcel.excelStr += '<ss:Cell ss:Index="' + (iH + 1).toString() + '" ' + sMerge +
														' ss:StyleID="' + (iR % 2 == 0 ? "even" : "odd") + '" ' + sUrlT + '><ss:Data ss:Type="String">' +
														sTextT + '</ss:Data></ss:Cell>';
												});
												dataExcel.excelStr += '</ss:Row>';
											});
										}
										dataExcel.excelStr +=
											'</ss:Table><x:WorksheetOptions><x:PageSetup><x:Layout x:CenterHorizontal="1" x:Orientation="Landscape" /><x:Footer x:Data="Page &P of &N" x:Margin="0.5" /><x:PageMargins x:Top="0.5" x:Right="0.5" x:Left="0.5" x:Bottom="0.8" /></x:PageSetup><x:FitToPage /><x:Print><x:PrintErrors>Blank</x:PrintErrors><x:FitWidth>1</x:FitWidth><x:FitHeight>32767</x:FitHeight><x:ValidPrinterInfo /><x:VerticalResolution>600</x:VerticalResolution></x:Print><x:Selected /><x:DoNotDisplayGridlines /><x:ProtectObjects>False</x:ProtectObjects><x:ProtectScenarios>False</x:ProtectScenarios></x:WorksheetOptions></ss:Worksheet><ss:ExcelWorkbook><ss:WindowHeight>9000</ss:WindowHeight><ss:WindowWidth>19340</ss:WindowWidth><ss:ProtectStructure>False</ss:ProtectStructure><ss:ProtectWindows>False</ss:ProtectWindows></ss:ExcelWorkbook></ss:Workbook>';
										if (Options["exportExcel"]) {
											Options["exportExcel"](dataExcel);
										}
									});
								}
							} else {
								$('#' + name + '_more').hide();
							}
						});
					}
					eleChild.id = ele.id + "_" + i;
					eleChild.style.display = "inline-block";
					if (i == arrHeader.length - 1) {
						eleChild.classList.add("borderRight");
					}
					eleChild.style.overflow = "hidden";
					eleChild.setAttribute("col", name + i);
					eleChild.style.height = (rowHeight - 1) + "px";
					eleChild.style.lineHeight = (rowHeight - 1) + "px";
					eleFrozen.appendChild(eleChild);

					BindDrag(eleChild, eleChild.id, name, i, arrHeader, UpdateScroll);
				}
			}
			eleFrozen.style.width = iFrozenWidth + 'px';
			if (!bHasHeader) {
				scrolltable.dom.appendChild(docFragFrozen);
			}
		}
		if (!bHasHeader) {
			scrolltable.dom.appendChild(docFrag);
		}
		if (Options["hideHeader"]) {
			$('#' + name + "_Header").hide();
			$('#' + name + "_Frozen_Header").hide();
		}

	}

	function More_Sort(issortbtn) {
		if ($("#" + name + "_sort_cancel").length > 0) {
			$("#" + name + "_sort_cancel")[0].addEventListener('click', function(e) {
				$('#' + name + "_more").hide();
			});
			$("#" + name + "_sort_ok")[0].addEventListener('click', function(e) {
				(function() {
					if (arrHeader.length > 0) {
						var element = $("#" + name + "_more_sort_list")[0];
						var arrHeaderNew = [];
						var bFrozenT = true;
						for (var iS = 0; iS < element.options.length; iS++) {
							var selText = element.options[iS].text;
							var selValue = element.options[iS].value;
							$.each(arrHeader, function(iH, valueH) {
								if (valueH["title"] == selText && valueH["field"] == selValue) {
									if (!valueH["frozen"]) {
										bFrozenT = false;
									}
									valueH["frozen"] = bFrozenT;
									arrHeaderNew.push(valueH);
									return false;
								}
							});
							$.each(dataBuffer, function(iB, valueB) {
								valueB["arrMerge"] = false;
							})
						}
						arrHeader = arrHeaderNew;
						createHeader();
						UpdateRowView();
						if (Options["saveConfig"]) {
							Options["saveConfig"](name, arrHeader);
						}
					}
					$('#' + name + "_more").hide();
				})();
			});
		}
		if ($("#" + name + "_more_up").length > 0) {
			$("#" + name + "_more_up")[0].addEventListener('click', function(e) {
				changepos($("#" + name + "_more_sort_list")[0], -1);
			});
			$("#" + name + "_more_down")[0].addEventListener('click', function(e) {
				changepos($("#" + name + "_more_sort_list")[0], 1);
			});
		}
		if (issortbtn && $("#" + name + "_more_sortcolumn").length > 0) {
			$("#" + name + "_more_sortcolumn")[0].addEventListener('click', function(e) {
				$('#' + name + '_more_content').html(sSortFilter);
				More_Sort(false);
			});
		}
		var $more_sort_list = document.querySelector("#" + name + "_more_sort_list");
		if ($more_sort_list) {
			arrHeader.forEach(function(item, index) {
				var objOption = document.createElement("option");
				objOption.text = item.title;
				objOption.value = item.field;
				objOption.disabled = !!item.disabled;
				$more_sort_list.appendChild(objOption);
			});
		}
	}

	function More_HideColumn(ishidebtn) {
		if ($("#" + name + "_hidecolumn_cancel").length > 0) {
			$("#" + name + "_hidecolumn_cancel")[0].addEventListener('click', function(e) {
				$('#' + name + "_more").hide();
			});
			$("#" + name + "_hidecolumn_ok")[0].addEventListener('click', function(e) {
				(function() {
					if (arrHeader.length > 0) {
						var element = $("#" + name + "_more_hidecolumn_chk input[type=\"checkbox\"]");
						var bFrozenT = true;
						for (var iS = 0; iS < element.length; iS++) {
							var selValue = element[iS].value;
							$.each(arrHeader, function(iH, valueH) {
								if ((valueH["field"] + "_" + valueH["title"]) == selValue) {
									if (!valueH["frozen"]) {
										bFrozenT = false;
									}
									valueH["frozen"] = bFrozenT;
									valueH["hide"] = !element[iS].checked;
									if (!valueH["hide"] && valueH["width"] == 0) {
										valueH["width"] = 100;
									}
									if (valueH["hide"]) {
										valueH["width"] = 0;
									}
									return false;
								}
							});
							$.each(dataBuffer, function(iB, valueB) {
								valueB["arrMerge"] = false;
							})
						}
						createHeader();
						UpdateRowView();
						sHideColumn = "<div id=\"" + name +
							"_more_hidecolumn_chk\" style=\"width:95%; height: 125px;overflow-x:auto;\">";
						$.each(arrHeader, function(iH, valueH) {
							var sHideColumnChk = "<input type=\"checkbox\" " + ((valueH["hide"] || valueH["width"] == 0) ? "" :
								"checked") + " value=\"" + valueH["field"] + "_" + valueH["title"] + "\"></input>" + valueH["title"];
							sHideColumn = sHideColumn + sHideColumnChk + "<br />";
						});
						sHideColumn = sHideColumn + "</div>";
						sHideColumn += '<div style="height:6px;"></div><input type="button" id="' + name + '_hidecolumn_ok" value="' +
							sBtnOk + '" style="margin-left: 3px;" />&nbsp;&nbsp;<input type="button" id="' + name +
							'_hidecolumn_cancel" value="' + sBtnCancel + '" />';
						if (Options["saveConfig"]) {
							Options["saveConfig"](name, arrHeader);
						}
					}
					$('#' + name + "_more").hide();
				})();
			});
		}
		if (ishidebtn && $("#" + name + "_more_hidecolumn").length > 0) {
			$("#" + name + "_more_hidecolumn")[0].addEventListener('click', function(e) {
				$('#' + name + '_more_content').html(sHideColumn);
				More_HideColumn(false);
			});
		}
	}

	function More_Search(issearchbtn) {
		if ($("#" + name + "_search_cancel").length > 0) {
			$("#" + name + "_search_cancel")[0].addEventListener('click', function(e) {
				$('#' + name + "_more").hide();
			});
			$("#" + name + "_search_ok")[0].addEventListener('click', function(e) {
				(function() {
					Search(true);
					$('#' + name + "_more").hide();
				})();
			});
		}
		if (issearchbtn && $("#" + name + "_more_searchbtn").length > 0) {
			$("#" + name + "_more_searchbtn")[0].addEventListener('click', function(e) {
				$('#' + name + '_more_content').html(sSearchFilter);
				More_Search(false);
				for (var j = 0; j < arrHeader.length; j++) {
					if (arrHeader[j].search) {
						$('#' + name + "_search_" + arrHeader[j].field).val(formatter(arrHeader[j], arrHeader[j].searchText));
					}
				}
				if ($("#" + name + "_search_cancel").length > 0) {
					$("#" + name + "_search_cancel")[0].addEventListener('click', function(e) {
						$('#' + name + "_more").hide();
					});
					$("#" + name + "_search_ok")[0].addEventListener('click', function(e) {
						(function() {
							Search(true);
							$('#' + name + "_more").hide();
						})();
					});
				}
			});
		}
	}

	/**
	 * 选中项添加到右边，左侧栏数据不删除，并且不能添加重复数据到右边
	 */
	function copyOption(obj, type) {
		var eleA = "";
		var eleB = "";
		if (type == "add") { //从左侧向右侧添加数据
			eleA = obj.parentNode.previousElementSibling.firstElementChild;
			eleB = obj.parentNode.nextElementSibling.firstElementChild;
		} else { //删除右侧数据
			eleA = obj.parentNode.nextElementSibling.firstElementChild;
			eleB = obj.parentNode.previousElementSibling.firstElementChild;
		}
		for (var i = 0; i < eleA.options.length; i++) {
			if (eleA.options[i].selected) {
				var eSelected = eleA.options[i];
				if (type == "add") {
					if (selectMember.indexOf(eSelected.text) < 0) { //判断左边选中项在右侧群成员列表中是否存在
						eleB.options.add(new Option(eSelected.text, eSelected.value)); //将选中项添加到右边
						selectMember.push(eSelected.text); //将选中值追加到selectMember[]中
					} else {
						alert("该项在右侧列表已经存在");
					}
				} else {
					eleA.remove(i); //移除选中项
					i = i - 1; //每移除一项，下拉选项的索引值会减1
					selectMember.splice($.inArray(eSelected.text, selectMember), 1); //将选中值从selectMember[]中移除
				}
			}
		}
	}
	/**
	 * 选中项左右移动
	 */
	function moveOption(eleA, eleB) {
		for (var i = 0; i < eleA.options.length; i++) {
			if (eleA.options[i].selected) {
				var eSelected = eleA.options[i];
				eleB.options.add(new Option(eSelected.text, eSelected.value)); //将选中项添加到右边
				eleA.remove(i); //移除选中项
				i = i - 1; //每移除一项，下拉选项的索引值会减1
			}
		}
	}
	/**
	 * 选中项上下移动
	 */
	function changepos(obj, index) {
		var element = obj; // obj.parentNode.previousElementSibling.childNodes[1];
		//选中项索引值
		var selectedIndex = element.options.selectedIndex;
		if (selectedIndex == -1) {
			return;
		}
		var selText = element.options[selectedIndex].text;
		var selValue = element.options[selectedIndex].value;
		//上移，上移时将选中项数据与上一条option数据进行交换
		if (index == -1) {
			if (selectedIndex > 0) {
				element.options[selectedIndex].text = element.options[selectedIndex - 1].text;
				element.options[selectedIndex].value = element.options[selectedIndex - 1].value;
				element.options[selectedIndex].selected = false;
				element.options[selectedIndex - 1].text = selText;
				element.options[selectedIndex - 1].value = selValue;
				element.options[selectedIndex - 1].selected = true;
			}
		}
		//下移，下移时将选中项数据与下一条option数据进行交换
		else if (index == 1) {
			if (selectedIndex < element.options.length - 1) {
				element.options[selectedIndex].text = element.options[selectedIndex + 1].text;
				element.options[selectedIndex].value = element.options[selectedIndex + 1].value;
				element.options[selectedIndex].selected = false;
				element.options[selectedIndex + 1].text = selText;
				element.options[selectedIndex + 1].value = selValue;
				element.options[selectedIndex + 1].selected = true;
			}
		}
	}


	function QuickSort(arr, index, bUp) {
		if (arr.length <= 1) {
			return arr;
		}
		var pivotIndex = Math.floor(arr.length / 2);
		var pivot = arr.splice(pivotIndex, 1)[0];
		var left = [];
		var right = [];

		for (var i = 0; i < arr.length; i++) {
			if (bUp) {
				if (arr[i][arrHeader[index].field] > pivot[arrHeader[index].field]) {
					arr[i]["arrMerge"] = undefined;
					left.push(arr[i]);
				} else {
					arr[i]["arrMerge"] = undefined;
					right.push(arr[i]);
				}
			} else {
				if (arr[i][arrHeader[index].field] < pivot[arrHeader[index].field]) {
					arr[i]["arrMerge"] = undefined;
					left.push(arr[i]);
				} else {
					arr[i]["arrMerge"] = undefined;
					right.push(arr[i]);
				}
			}
		}
		return QuickSort(left, index, bUp).concat([pivot], QuickSort(right, index, bUp));
	};

	function UpdateScroll() {
		var iMaxWidth = scrolltable.dom.offsetWidth;
		var iSrollWidth = 0;
		var iFrozenWidth = 0;
		for (var i = 0; i < arrHeader.length; i++) {
			if (arrHeader[i]["hide"]) {
				continue;
			}
			iSrollWidth += arrHeader[i].width;
			if (arrHeader[i].frozen) {
				iFrozenWidth += arrHeader[i].width;
			}
		}
		if (iSrollWidth < iMaxWidth) {
			iSrollWidth = 0;
		} else {
			iMaxWidth = iSrollWidth;
		}
		document.getElementById(name + "_ScrollerWidth").style.width = (iMaxWidth) + 'px';
		document.getElementById(name + '_BufferView').style.width = (iMaxWidth) + 'px';
		if (Options["isMobile"]) {
			document.getElementById(name + '_BufferView').style.width = "100%";
			document.getElementById(name + "_ScrollerWidth").style.width = document.getElementById(name + '_BufferView').style.width;
		}
		//document.getElementById(name + '_BufferAllView').style.width = document.getElementById(name + '_BufferActualDomain').offsetWidth + 'px';
		document.getElementById(name + '_BufferAllView').style.width = document.getElementById(name).offsetWidth + 'px';
		document.getElementById(name + '_Header').style.width = (iMaxWidth) + 'px';
		if (bFrozen) {
			document.getElementById(name + '_Frozen_BufferView').style.width = (iFrozenWidth) + 'px';
			document.getElementById(name + '_Frozen_Header').style.width = (iFrozenWidth) + 'px';
			document.getElementById(name + '_Frozen_AllContainer').style.width = (iFrozenWidth) + 'px';
			document.getElementById(name + '_Frozen_BufferContainer').style.width = (iFrozenWidth) + 'px';
		}
		if (!Options["isMobile"]) {
			$('#' + name + '_Scroller').niceScroll().resize();
			$('#' + name + '_BufferContainer').niceScroll({
				horizrailenabled: false
			}).resize();
		}
	}

	function on(evtName, handler, bobble) {
		if (window.attachEvent) {
			this.dom.attachEvent("on" + evtName, handler);
		} else if (window.addEventListener) {
			try {
				window.addEventListener.call(this.dom, evtName, handler, !!bobble);
			} catch (e) {
				this.dom.addEventListener(evtName, handler);
			}
		}
		//addEventListener.call(this.dom, evtName, handler, !!bobble);
	}

	function createBuffer() {
		//冻结列
		var iFrozenWidth = 0;
		var docFrozenFrag = undefined;
		if (true) {
			var docFrag = document.createDocumentFragment();
			var ele = document.createElement('div');
			ele.classList.add("viewBufferContainer");
			ele.style.height = (scrolltable.dom.offsetHeight - rowHeight) + 'px';
			if (Options["hideHeader"]) {
				ele.style.height = (scrolltable.dom.offsetHeight) + 'px';
			}
			ele.id = name + "_BufferContainer";
			ele.style.overflowX = "hidden";
			docFrag.appendChild(ele);

			var eleChildT = document.createElement('div');
			eleChildT.classList.add("buffer-view");
			eleChildT.id = name + "_BufferAllView";
			eleChildT.style.overflowX = "hidden";
			eleChildT.style.overflowY = "hidden";
			eleChildT.style.width = $('#' + name)[0].offsetWidth - iScrollbarWidth;
			eleChildT.style.position = "relative";
			eleChildT.style.height = (scrolltable.dom.offsetHeight - rowHeight) + 'px';
			if (Options["hideHeader"]) {
				//eleChildT.style.top = rowHeight + "px";
				eleChildT.style.height = (scrolltable.dom.offsetHeight) + 'px';
			}
			//eleChildT.style.height = "100%";
			//eleChildT.style.top = "0px";
			//eleChildT.style.left= "0px";
			docFrag.appendChild(eleChildT);

			if (Options["isMobile"]) {
				var eleChildTouch = document.createElement('div');
				eleChildTouch.classList.add("buffer-touch-view");
				eleChildTouch.id = name + "_BufferTouchView";
				eleChildTouch.style.overflowX = "hidden";
				eleChildTouch.style.overflowY = "hidden";
				//eleChildTouch.style.width = $('#' + name)[0].offsetWidth - iScrollbarWidth;
				//eleChildTouch.style.height = "100%";
				eleChildT.appendChild(eleChildTouch);
			}

			if (bFrozen) {
				for (var i = 0; i < arrHeader.length; i++) {
					if (arrHeader[i]["frozen"]) {
						iFrozenWidth += arrHeader[i].width;
					}
				}
				docFrozenFrag = document.createDocumentFragment();
				var eleFrozenParent = document.createElement('div');
				eleFrozenParent.style.position = "absolute";
				eleFrozenParent.id = name + "_Frozen_AllContainer";
				eleFrozenParent.style.left = '0px';
				eleFrozenParent.style.top = rowHeight + 'px';
				eleFrozenParent.style.width = iFrozenWidth;
				eleFrozenParent.style.height = "100%";
				docFrozenFrag.appendChild(eleFrozenParent);

				var eleFrozen = document.createElement('div');
				eleFrozen.style.position = "absolute";
				eleFrozen.style.height = (scrolltable.dom.offsetHeight - rowHeight) + 'px';
				eleFrozen.id = name + "_Frozen_BufferContainer";
				eleFrozen.style.overflowX = "hidden";
				eleFrozen.style.width = iFrozenWidth;
				eleFrozen.style.position = "absolute";
				eleFrozen.style.left = '0px';
				eleFrozen.style.top = '0px';
				eleFrozen.style.zIndex = 201;
				eleFrozen.style.overflow = "hidden";
				eleFrozenParent.appendChild(eleFrozen);

				var eleeleFrozenChild = document.createElement('div');
				eleeleFrozenChild.classList.add("buffer-frozen-view");
				eleeleFrozenChild.id = name + "_Frozen_BufferView";
				eleeleFrozenChild.style.overflowX = "hidden";
				eleeleFrozenChild.style.boxSizing = "border-box";
				//eleeleFrozenChild.classList.add("borderRight");
				eleeleFrozenChild.style.zIndex = 201;
				eleFrozenParent.appendChild(eleeleFrozenChild);
				eleFrozenParent.addEventListener('dblclick', function(e) {
					eleeleFrozenChild.classList.add("noselect");
					var text = this;
					setTimeout(function() {
						if (document.body.createTextRange) {
							var range = document.body.createTextRange();
							range.moveToElementText(text);
							range.select();
						} else if (window.getSelection) {
							var selection = window.getSelection();
							var range = document.createRange();
							//range.selectNodeContents(text);
							selection.removeAllRanges();
							selection.addRange(range);

						} else {
							//alert("none");
						}
						eleeleFrozenChild.classList.remove("noselect");

					}, 5);
				});

				// eleChild = document.createElement('div');
				// eleChild.classList.add("actual-domain");
				// eleChild.id = name + "_BufferActualDomain";
				// ele.appendChild(eleChild);
			}

			var eleChild = document.createElement('div');
			eleChild.classList.add("buffer-view");
			eleChild.id = name + "_BufferView";
			eleChild.style.overflowX = "hidden";
			eleChild.style.width = $('#' + name)[0].offsetWidth - iScrollbarWidth;
			eleChildT.appendChild(eleChild);

			eleChildT.addEventListener('dblclick', function(e) {
				var text = this;
				eleChildT.classList.add("noselect");
				setTimeout(function() {
					if (document.body.createTextRange) {
						var range = document.body.createTextRange();
						range.moveToElementText(text);
						range.select();
					} else if (window.getSelection) {
						var selection = window.getSelection();
						var range = document.createRange();
						//range.selectNodeContents(text);
						selection.removeAllRanges();
						selection.addRange(range);

					} else {
						//alert("none");
					}
					eleChildT.classList.remove("noselect");

				}, 5);
			});


			eleChild = document.createElement('div');
			eleChild.classList.add("actual-domain");
			eleChild.id = name + "_BufferActualDomain";
			ele.appendChild(eleChild);
			scrolltable.dom.appendChild(docFrag);

			//滚动条
			docFrag = document.createDocumentFragment();
			var ele = document.createElement('div');
			ele.style.height = '20px';
			ele.id = name + "_Scroller";
			ele.style.display = "inline-block";
			ele.style.lineHeight = '20px';
			ele.style.whiteSpace = "nowrap";
			ele.style.overflowY = "hidden";
			ele.style.overflowX = "auto";
			ele.style.position = "absolute";
			ele.style.top = (scrolltable.dom.offsetHeight - 20) + 'px';
			ele.style.left = '0px';
			ele.style.zIndex = 400;
			var iMaxWidth = scrolltable.dom.offsetWidth;
			var iSrollWidth = 0;
			for (var i = 0; i < arrHeader.length; i++) {
				//iSrollWidth += arrHeader[i].width + 10;
				iSrollWidth += arrHeader[i].width;
			}
			if (iSrollWidth < iMaxWidth) {
				iSrollWidth = 0;
			}

			ele.innerHTML = '<div id="' + name + '_ScrollerWidth" style="width: ' + iSrollWidth +
				'px;">&nbsp;</div>';
			if (Options["isMobile"]) {
				ele.innerHTML = '<div id="' + name + '_ScrollerWidth" style="width: 90%;">&nbsp;</div>';
			}
			docFrag.appendChild(ele);
			scrolltable.dom.appendChild(docFrag);
			if (bFrozen) {
				scrolltable.dom.appendChild(docFrozenFrag);
				divFrozenBufferView = scrolltable.SelectByID('Frozen_BufferView');
			}
			scrolltable.SelectByID('Scroller').on('scroll', function(evt, obj) {
				var offset = scrolltable.SelectByID('Scroller').offset();
				if (offset.left != undefined) {
					document.getElementById(name + "_Header").style.left = (-offset.left) + 'px';
					document.getElementById(name + "_BufferView").style.left = (-offset.left) + 'px';
				}
			})

			//分页
			docFrag = document.createDocumentFragment();
			ele = document.createElement('div');
			ele.className = "tablefooter";
			ele.id = name + "_tablefooter";
			ele.style.display = "none";
			ele.style.lineHeight = '20px';
			ele.style.whiteSpace = "nowrap";
			ele.style.overflowY = "hidden";
			ele.style.overflowX = "hidden";
			ele.style.position = "absolute";
			ele.style.top = (scrolltable.dom.offsetHeight - 20) + 'px';
			ele.style.left = '0px';
			ele.style.zIndex = 405;
			ele.innerHTML =
				'<div class="tablenav"><div><img class="first" src="images/first.gif" width="16" height="16" alt="First Page" />' +
				'<img class="previous" src="images/previous.gif" width="16" height="16" alt="First Page" />' +
				'<img class="next" src="images/next.gif" width="16" height="16" alt="First Page" />' +
				'<img class="last" src="images/last.gif" width="16" height="16" alt="Last Page" />' +
				'</div><div><select id="' + name +
				'_pagedropdown" class="pagedropdown" ></select ></div ><div class="crossx"></div></div > ';
			docFrag.appendChild(ele);
			scrolltable.dom.appendChild(docFrag);
			$(ele).find(".crossx")[0].addEventListener('click', function(e) {
				document.getElementById(name + '_pagedropdown').bypass = false;
				$("#" + name + "_tablefooter").hide();
			});
			$(ele).find(".first")[0].addEventListener('click', function(e) {
				scrollToIndex(1);
			});
			$(ele).find(".previous")[0].addEventListener('click', function(e) {
				(function(eleT, iPagingIndexT, iPagingCountT) {
					if (iPagingIndexT > 1) {
						iPagingIndexT = iPagingIndexT - 1;
						scrollToIndex(((iPagingIndexT - 1) * iPagingCountT) + 1);
					}
				})(ele, iPagingIndex, iPagingCount);
			});
			$(ele).find(".next")[0].addEventListener('click', function(e) {
				(function(eleT, iPagingIndexT, iPagingCountT) {
					var arrSearchDataT = [];
					$.each(dataBuffer, function(i, value) {
						if (!value["searchdisable"]) {
							arrSearchDataT.push(value);
						}
					});
					var iPagingCountAllT = Math.ceil(arrSearchDataT.length / (iPagingCountT * 1.0));
					if (iPagingIndexT < iPagingCountAllT) {
						iPagingIndexT = iPagingIndexT + 1;
						scrollToIndex(((iPagingIndexT - 1) * iPagingCountT) + 1);
					}
				})(ele, iPagingIndex, iPagingCount);
			});

			$(ele).find(".last")[0].addEventListener('click', function(e) {
				(function(eleT, iPagingIndexT, iPagingCountT) {
					var arrSearchDataT = [];
					$.each(dataBuffer, function(i, value) {
						if (!value["searchdisable"]) {
							arrSearchDataT.push(value);
						}
					});
					var iPagingCountAllT = Math.ceil(arrSearchDataT.length / (iPagingCountT * 1.0));
					scrollToIndex(((iPagingCountAllT - 1) * iPagingCount) + 1);
				})(ele, iPagingIndex, iPagingCount);
			});
			$(ele).find(".pagedropdown")[0].addEventListener('change', function(e) {
				setTimeout(function() {
					document.getElementById(name + '_pagedropdown').bypass = false;
				}, 1000);
				(function(iPagingCountT) {
					var iIndexT = (parseInt($("#" + name + "_pagedropdown")[0].value));
					scrollToIndex((iIndexT - 1) * iPagingCountT + 1);
				})(iPagingCount);
			});
			$(ele).find(".pagedropdown")[0].options.length = 0;
			$(ele).find(".pagedropdown").append("<option value='1'>1</option>");
			/* if(Options["isMobile"]){
				$('#' + name + "_BufferContainer").hide();
				$('#' + name + "_Scroller").hide();
			} */
		}
	}

	function dom(selector) {
		return typeof selector === 'object' ?
			selector :
			document.querySelector(selector);
	}


	function offset() {
		var iTop = this.dom.scrollTop;
		//    if (iTop == undefined) {
		//        iTop = getScrollTop();
		//    }
		return {
			left: this.dom.scrollLeft,
			top: iTop
		};
	}

	function getScrollTop() {
		var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
		return scrollTop;
	}

	function height(val) {
		if (isNaN(val)) {
			return this.dom.clientHeight;
		} else {
			this.dom.style.height = val + "px";
			return this;
		}
	}

	function text(str) {
		this.dom.innerText = str;
		return this;
	}

	function css(attrs) {
		for (var attr in attrs) {
			if (attrs.hasOwnProperty(attr)) {
				this.dom.style[attr] = attrs[attr] + 'px';
			}
		}
	}

	function append(tagName, size) {
		var docFrag = document.createDocumentFragment();
		var docFragFrozen = document.createDocumentFragment();
		var clickDom = undefined;
		var iMaxWidth = scrolltable.dom.offsetWidth;
		var iSrollWidth = 0;
		var iFrozenWidth = 0;
		for (var i = 0; i < arrHeader.length; i++) {
			iSrollWidth += arrHeader[i].width;
			if (arrHeader[i].frozen) {
				iFrozenWidth += arrHeader[i].width;
			}
		}
		if (iSrollWidth > iMaxWidth) {
			iMaxWidth = iSrollWidth;
		}
		while (size-- >= 0) {
			var ele = document.createElement(tagName);
			ele.style.height = rowHeight + "px";
			ele.style.lineHeight = rowHeight + "px";
			ele.style.padding = "0";
			ele.style.margin = "0";
			ele.style.boxSizing = "border-box";
			ele.style.display = "inline-block";
			ele.style.whiteSpace = "nowrap";
			ele.style.width = '100%';
			ele.classList.add("borderTop");
			ele.id = "";
			if (size == -1) {
				ele.style.borderBottom = "1px solid #e6e6e6";
			}

			var divFrozen = undefined;
			if (bFrozen) {
				divFrozen = document.createElement(tagName);
				divFrozen.style.height = rowHeight + "px";
				divFrozen.style.lineHeight = rowHeight + "px";
				divFrozen.style.padding = "0";
				divFrozen.style.margin = "0";
				divFrozen.style.boxSizing = "border-box";
				divFrozen.style.display = "inline-block";
				divFrozen.style.whiteSpace = "nowrap";
				divFrozen.style.width = '100%';
				divFrozen.classList.add("borderTop");
				divFrozen.id = "";
				if (size == -1) {
					divFrozen.style.borderBottom = "1px solid #e6e6e6";
				}
				divFrozen.addEventListener('mouseover', function(e) {
					if (e.currentTarget["id"] == "" || e.currentTarget["NewID"] == "") {
						return;
					}
					var child = e.currentTarget.firstChild;
					var last = e.currentTarget.lastChild;
					while (child != last) {
						if (child.nodeType == 1) {
							//child.classList.add("mouseovercolor");
							var elelist = document.querySelectorAll('[row="' + child.attributes["row"].value + '"]');
							for (var ii = 0; ii < elelist.length; ii++) {
								elelist[ii].classList.add("mouseovercolor");
							}
						}
						child = child.nextSibling;
					}
					if (last != undefined && last.nodeType == 1) {
						//last.classList.add("mouseovercolor");
						var elelist = document.querySelectorAll('[row="' + last.attributes["row"].value + '"]');
						for (var ii = 0; ii < elelist.length; ii++) {
							elelist[ii].classList.add("mouseovercolor");
						}
					}
				});
				divFrozen.addEventListener('mouseout', function(e) {
					if (e.currentTarget["id"] == "" || e.currentTarget["NewID"] == "") {
						return;
					}
					var child = e.currentTarget.firstChild;
					var last = e.currentTarget.lastChild;
					while (child != last) {
						if (child.nodeType == 1) {
							//child.classList.remove("mouseovercolor");
							var elelist = document.querySelectorAll('[row="' + child.attributes["row"].value + '"]');
							for (var ii = 0; ii < elelist.length; ii++) {
								elelist[ii].classList.remove("mouseovercolor");
							}
						}
						child = child.nextSibling;
					}
					if (last != undefined && last.nodeType == 1) {
						//last.classList.remove("mouseovercolor");
						var elelist = document.querySelectorAll('[row="' + last.attributes["row"].value + '"]');
						for (var ii = 0; ii < elelist.length; ii++) {
							elelist[ii].classList.remove("mouseovercolor");
						}
					}
				});
				divFrozen.addEventListener('dblclick', function(e) {
					if (e.currentTarget["id"] == "" || e.currentTarget["NewID"] == "") {
						return;
					}
					if (Options != undefined && Options["dblclick"] != undefined) {
						for (var i = 0; i < dataBuffer.length; i++) {
							if (dataBuffer[i][sKey] == e.currentTarget["NewID"]) {
								Options["dblclick"](dataBuffer[i]);
							}
						}
					}
				});
				divFrozen.addEventListener('contextmenu', function(e) {
					if (e.currentTarget["id"] == "" || e.currentTarget["NewID"] == "") {
						return;
					}
					if (Options != undefined && Options["contextmenuClick"] != undefined) {
						for (var i = 0; i < dataBuffer.length; i++) {
							if (dataBuffer[i][sKey] == e.currentTarget["NewID"]) {
								Options["contextmenuClick"](e, dataBuffer[i]);
							}
						}
					}
				});
				divFrozen.addEventListener('click', function(e) {
					if (e.currentTarget["id"] == "" || e.currentTarget["NewID"] == "") {
						return;
					}
					if (clickDom != undefined) {
						var child = clickDom.firstChild;
						var last = clickDom.lastChild;
						while (child != last) {
							if (child.nodeType == 1) {
								var elelist = document.querySelectorAll('[row="' + child.attributes["row"].value + '"]');
								for (var ii = 0; ii < elelist.length; ii++) {
									elelist[ii].classList.remove("mouseclickcolor");
								}
							}
							child = child.nextSibling;
						}
						if (last != undefined && last.nodeType == 1) {
							var elelist = document.querySelectorAll('[row="' + last.attributes["row"].value + '"]');
							for (var ii = 0; ii < elelist.length; ii++) {
								elelist[ii].classList.remove("mouseclickcolor");
							}
						}
					}
					clickDom = e.currentTarget;
					if (Options != undefined && Options["click"] != undefined) {
						for (var i = 0; i < dataBuffer.length; i++) {
							if (dataBuffer[i][sKey] == e.currentTarget["NewID"]) {
								Options["click"](dataBuffer[i]);
							}
						}
					}
					iClickIndex = clickDom["NewID"];
					var child = e.currentTarget.firstChild;
					var last = e.currentTarget.lastChild;
					while (child != last) {
						if (child.nodeType == 1) {
							var elelist = document.querySelectorAll('[row="' + child.attributes["row"].value + '"]');
							for (var ii = 0; ii < elelist.length; ii++) {
								elelist[ii].classList.add("mouseclickcolor");
							}
						}
						child = child.nextSibling;
					}
					if (last != undefined && last.nodeType == 1) {
						var elelist = document.querySelectorAll('[row="' + last.attributes["row"].value + '"]');
						for (var ii = 0; ii < elelist.length; ii++) {
							elelist[ii].classList.add("mouseclickcolor");
						}
					}
				});
				docFragFrozen.appendChild(divFrozen);
			}
			ele.addEventListener('dblclick', function(e) {
				if (e.currentTarget["id"] == "" || e.currentTarget["NewID"] == "") {
					return;
				}
				if (Options != undefined && Options["dblclick"] != undefined) {
					for (var i = 0; i < dataBuffer.length; i++) {
						if (dataBuffer[i][sKey] == e.currentTarget["NewID"]) {
							Options["dblclick"](dataBuffer[i]);
						}
					}
				}
			});
			ele.addEventListener('contextmenu', function(e) {
				if (e.currentTarget["id"] == "" || e.currentTarget["NewID"] == "") {
					return;
				}
				if (Options != undefined && Options["contextmenuClick"] != undefined) {
					for (var i = 0; i < dataBuffer.length; i++) {
						if (dataBuffer[i][sKey] == e.currentTarget["NewID"]) {
							Options["contextmenuClick"](e, dataBuffer[i]);
						}
					}
				}
			});
			ele.addEventListener('mouseover', function(e) {
				if (e.currentTarget["id"] == "" || e.currentTarget["NewID"] == "") {
					return;
				}
				var child = e.currentTarget.firstChild;
				var last = e.currentTarget.lastChild;
				while (child != last) {
					if (child.nodeType == 1) {
						//child.classList.add("mouseovercolor");
						var elelist = document.querySelectorAll('[row="' + child.attributes["row"].value + '"]');
						for (var ii = 0; ii < elelist.length; ii++) {
							elelist[ii].classList.add("mouseovercolor");
						}
					}
					child = child.nextSibling;
				}
				if (last != undefined && last.nodeType == 1) {
					last.classList.add("mouseovercolor");
				}
				if (Options["isMobile"]) {
					e.currentTarget.classList.add("mouseovercolor");
				}
			});
			ele.addEventListener('mouseout', function(e) {
				var child = e.currentTarget.firstChild;
				var last = e.currentTarget.lastChild;
				while (child != last) {
					if (child.nodeType == 1) {
						var elelist = document.querySelectorAll('[row="' + child.attributes["row"].value + '"]');
						for (var ii = 0; ii < elelist.length; ii++) {
							elelist[ii].classList.remove("mouseovercolor");
						}
						if (Options["isMobile"]) {
							document.getElementById(child.id).classList.remove("mouseovercolor");
						}
					}
					child = child.nextSibling;
				}
				if (last != undefined && last.nodeType == 1) {
					last.classList.remove("mouseovercolor");
				}
				if (Options["isMobile"]) {
					e.currentTarget.classList.remove("mouseovercolor");
				}
			});
			ele.addEventListener('touchstart', function(e) {
				if (e.currentTarget["id"] == "" || e.currentTarget["NewID"] == "") {
					return;
				}
				var sNewIDT = e.currentTarget["NewID"];
				iClickMobile++;
				setTimeout(function() {
					if (iClickMobile == 0) {
						if (Options != undefined && Options["click"] != undefined) {
							for (var i = 0; i < dataBuffer.length; i++) {
								if (dataBuffer[i][sKey] == sNewIDT) {
									Options["click"](dataBuffer[i]);
								}
							}
						}
					}
					iClickMobile = 0;
				}, 200);
				if (iClickMobile > 1 && Options["isMobile"]) {
					iClickMobile = 0;
					if (Options != undefined && Options["dblclick"] != undefined) {
						for (var i = 0; i < dataBuffer.length; i++) {
							if (dataBuffer[i][sKey] == sNewIDT) {
								Options["dblclick"](dataBuffer[i]);
							}
						}
					}
				}
			});
			ele.addEventListener('click', function(e) {
				if (e.currentTarget["id"] == "" || e.currentTarget["NewID"] == "") {
					return;
				}
				if (clickDom != undefined) {
					var child = clickDom.firstChild;
					var last = clickDom.lastChild;
					while (child != last) {
						if (child.nodeType == 1) {
							var elelist = document.querySelectorAll('[row="' + child.attributes["row"].value + '"]');
							for (var ii = 0; ii < elelist.length; ii++) {
								elelist[ii].classList.remove("mouseclickcolor");
								elelist[ii].classList.remove("mouseovercolor");
							}
							if (Options["isMobile"]) {
								document.getElementById(child.id).classList.remove("mouseovercolor");
								document.getElementById(child.id).classList.remove("mouseclickcolor");
							}
						}
						child = child.nextSibling;
					}
					if (last != undefined && last.nodeType == 1) {
						last.classList.remove("mouseclickcolor");
						last.classList.remove("mouseovercolor");
					}
					if (Options["isMobile"]) {
						clickDom.classList.remove("mouseclickcolor");
						clickDom.classList.remove("mouseovercolor");
					}
				}
				clickDom = e.currentTarget;
				if (Options != undefined && Options["click"] != undefined) {
					for (var i = 0; i < dataBuffer.length; i++) {
						if (dataBuffer[i][sKey] == e.currentTarget["NewID"]) {
							Options["click"](dataBuffer[i]);
						}
					}
				}

				iClickIndex = clickDom["NewID"];
				var child = e.currentTarget.firstChild;
				var last = e.currentTarget.lastChild;
				while (child != last) {
					if (child.nodeType == 1) {
						var elelist = document.querySelectorAll('[row="' + child.attributes["row"].value + '"]');
						for (var ii = 0; ii < elelist.length; ii++) {
							elelist[ii].classList.add("mouseclickcolor");
						}
						if (Options["isMobile"]) {
							document.getElementById(child.id).classList.add("mouseclickcolor");
						}
					}
					child = child.nextSibling;
				}
				if (last != undefined && last.nodeType == 1) {
					last.classList.add("mouseclickcolor");
				}
				if (Options["isMobile"]) {
					clickDom.classList.add("mouseclickcolor");
				}
			});
			docFrag.appendChild(ele);

		}

		this.dom.appendChild(docFrag);
		if (bFrozen) {
			scrolltable.SelectByID('Frozen_BufferView').dom.appendChild(docFragFrozen);
		}
	}

	function appendUpdate(tagName, size) {
		removeAllChild(divBufferView.dom);
		for (var i = 0; i < arrHeader.length; i++) {
			if (arrHeader[i].frozen) {
				removeAllChild(scrolltable.SelectByID('Frozen_BufferView').dom);
				break;
			}
		}
		divBufferView.append(tagName, size);
		//     var docFrag = document.createDocumentFragment();
		//     while (size-- >= 0) {
		//         docFrag.appendChild(document.createElement(tagName));
		//     }
		// 
		//     divBufferView.dom.appendChild(docFrag);
	}

	function removeAllChild(docFrag) {
		if (docFrag == undefined) {
			return;
		}
		while (docFrag.hasChildNodes()) //当div下还存在子节点时 循环继续 
		{
			docFrag.removeChild(docFrag.firstChild);
		}
	}

	function iniData(data) {
		dataBuffer = data;
		arrDataInterVal = [];
		iSearchdisableCount = 0;
		arrShowTrue = [];
		arrBufferKeyIndex = [];
		for (var i = 0; i < dataBuffer.length; i++) {
			arrBufferKeyIndex[dataBuffer[i][sKey]] = i;
			if (dataBuffer[i]["searchdisable"]) {
				iSearchdisableCount++;
			} else {
				arrShowTrue.push(dataBuffer[i]);
			}
		}
		iSearchdisableCount = data.length - iSearchdisableCount;
		bGlobalSetData = false;
		updateHeight();
		bGlobalSetData = true;
		scrollToIndex(0);
	}

	function setData(data, IsUpdateHeight) {
		if (!bGlobalSetData) {
			return;
		}
		if (IsUpdateHeight) {
			updateHeight();
			return;
		}
		dataViewBuffer = [];
		var divFrozen = scrolltable.SelectByID('Frozen_BufferView');
		var childs = divBufferView.dom.childNodes;
		var FrozenChilds = [];
		if (bFrozen) {
			FrozenChilds = divFrozen.dom.childNodes;
		}
		while (childs.length < data.length || data.length > iPagingCount) {
			data.splice(data.length - 1, 1);
		}
		for (var i = 0; i < childs.length; i++) {
			childs[i].innerText = "";
			childs[i]["id"] = "";
			if (!Options["isMobile"]) {
				childs[i].innerHTML = "";
			}
			childs[i].classList.remove("borderTop");
			if (i < data.length) {
				//childs[i].classList.add("borderBottom");
			}
		}
		if (bFrozen) {
			for (var i = 0; i < FrozenChilds.length; i++) {
				FrozenChilds[i].innerText = "";
				FrozenChilds[i]["id"] = "";
				FrozenChilds[i].innerHTML = "";
				FrozenChilds[i].classList.remove("borderTop");
				FrozenChilds[i].classList.remove("borderBottom");
				FrozenChilds[i].classList.remove("borderBottom");
				if (i < data.length) {
					//FrozenChilds[i].classList.add("borderBottom");
				}
			}
		}
		var bTop = true;
		var sTopBorder = ""; //"borderTop";
		var lastNode = undefined;
		if (true) { //childs.forEach == undefined) {
			for (var i = 0; i < data.length; i++) {
				var node = childs[i];
				node["id"] = "";
				node.classList.remove("borderTop");
				node.classList.remove("borderBottom");
				var nodeFrozen = undefined;
				if (bFrozen) {
					nodeFrozen = FrozenChilds[i];
					nodeFrozen["id"] = "";
					nodeFrozen.classList.remove("borderTop");
					nodeFrozen.classList.remove("borderBottom");
				}
				if (i > data.length - 1) {
					node.innerText = "";
					node["NewID"] = "";
					if (lastNode != undefined) {
						//node.classList.add("borderTop");
					}
					if (bFrozen) {
						nodeFrozen.innerText = "";
						nodeFrozen["NewID"] = "";
						if (lastNode != undefined) {
							//nodeFrozen.classList.add("borderTop");
						}
					}
					lastNode = undefined;
				} else {
					if (!Options["isMobile"]) {
						node.innerHTML = "";
					}
					//node.classList.add("borderTop");
					if (bFrozen) {
						nodeFrozen.innerText = "";
						///nodeFrozen.classList.add("borderTop");
					}
					var sMobileMain = ""; //单行
					var sMibile1 = ""; //主标题
					var sMibile2 = ""; //次标题
					var sMibile3 = ""; //详细内容
					var sMibile4 = ""; //其它
					var sMibile0 = ""; //右边内容
					var iMibileCount = 0;
					for (var j = 0; j < arrHeader.length; j++) {
						if (arrHeader[j]["hide"]) {
							continue;
						}
						var classL = " borderLeft";
						var classB = " borderBottom";
						var sTextDiv = arrHeader[j].formatter(data[i], data[i][arrHeader[j].field]);
						if (arrHeader[j]["mobileSn"] || arrHeader[j]["mobileSn"] == 0) {
							iMibileCount++;
							switch (arrHeader[j]["mobileSn"]) {
								case 1:
									//sMibile1 = "<div style=\"float:left;position: relative; top:-25px;\" class=\"momile_cell_table_left_main\">" + sTextDiv + "</div>";
									sMibile1 = "<div class=\"momile_cell_table_left_main\">" + sTextDiv + "</div>";
									sMobileMain = "<div class=\"momile_cell_table_left_onlymain\">" + sTextDiv + "</div>";
									break;
								case 2:
									sMibile2 = "<div class=\"momile_cell_table_left_second\">" + sTextDiv + "</div>";
									break;
								case 3:
									sMibile3 = "<div class=\"momile_cell_table_left_third\">" + sTextDiv + "</div>";
									break;
								case 4:
									sMibile4 = "<div class=\"momile_cell_table_left_other\">" + sTextDiv + "</div>";
									break;
								case 0:
									/* if(sTextDiv.length == 0){
										sTextDiv = "&nbsp;";
									} */
									iMibileCount--;
									sMibile0 = "<div class=\"momile_cell_table_right\" style=\"height:" + rowHeight + "px\">" + sTextDiv +
										"</div>";
									break;
							}
						}
						if (data[i]["arrMerge"]) {
							$.each(data[i]["arrMerge"], function(iM, valueM) {
								if (valueM.c.c == (j + 1)) {
									//同一列
									if (valueM.c.r > 1 && valueM.sn != 2) {
										classB = "";
									}
									if (valueM.sn > 0) {
										sTextDiv = "";
									}
								} else if (valueM.c.c <= j && (valueM.c.c + valueM.c.cl - 2) >= (j)) {
									classL = "";
									if (!valueM.b) {
										classB = "";
									}
									if (valueM.sn > 0) {
										sTextDiv = "";
									}
								}
							});
						}
						var classBorder = classL + classB;
						if (arrHeader[j].frozen) {
							nodeFrozen.innerHTML += "<div id='" + name + "_frozen_row" + data[i][sKey] + "_coln" + j + "' row='" + name +
								data[i][sKey] + "' col='" + name + j + "' style='width:" +
								arrHeader[j].width +
								"px; height:" + (rowHeight - 1) + "px; line-height:" + (rowHeight - 1) + "px;' class='" + classBorder +
								" spanRow " + (j == 0 ? " " :
									" ") + sTopBorder +
								" '>" + sTextDiv + "</div>";
						}
						if (!Options["isMobile"]) {
							node.innerHTML += "<div id='" + name + "_row" + data[i][sKey] + "_coln" + j + "' row='" + name + data[i][sKey] +
								"' col='" + name + j + "' style='width:" +
								arrHeader[j].width +
								"px; height:" + (rowHeight - 1) + "px; line-height:" + (rowHeight - 1) + "px;' class='" + classBorder +
								" spanRow " + (j == 0 ? " " :
									" ") + sTopBorder +
								" '>" + sTextDiv + "</div>";
						}
					}
					if (!Options["isMobile"]) {
						node.innerHTML += "<div id='" + name + "_row" + data[i][sKey] + "_coln" + arrHeader.length + "' row='" + name +
							data[i][sKey] + "' col='" + name +
							arrHeader.length + "' style='width:100%;display:inline-block;height:" +
							(rowHeight - 1) + "px; line-height:" + (rowHeight - 1) + "px;' class=' borderLeft" + classBorder +
							" spanRow borderRight " + sTopBorder +
							" '></div>";
					}
					node["NewID"] = data[i][sKey];
					node["id"] = name + "_row_" + data[i][sKey];
					if (Options["isMobile"]) {
						if (iMibileCount == 1 && sMibile0.length == 0) {
							node.innerHTML = sMobileMain;
						} else if (iMibileCount == 1 && sMibile0.length > 0) {
							node.innerHTML = "<div class=\"momile_cell\" style=\"height:" + rowHeight +
								"px\" ><div class=\"momile_cell_table\" style=\"height:" + rowHeight +
								"px\" ><div class=\"momile_cell_table_left\" style=\"height:" + rowHeight + "px\" >" + sMobileMain + "</div>" +
								sMibile0 + "</div></div>";
						} else if (sMibile0.length > 0) {
							node.innerHTML = "<div class=\"momile_cell\"><div class=\"momile_cell_table\" style=\"height:" + rowHeight +
								"px\" ><div class=\"momile_cell_table_left\" style=\"height:" + rowHeight + "px\" >" + sMibile1 + sMibile2 +
								sMibile3 + sMibile4 + "</div>" + sMibile0 + "</div></div>";
						} else {
							node.innerHTML = "<div class=\"momile_cell\"><div class=\"momile_cell_table\" style=\"height:" + rowHeight +
								"px\" ><div class=\"momile_cell_table_all\" style=\"height:" + rowHeight + "px\" >" + sMibile1 + sMibile2 +
								sMibile3 + sMibile4 + "</div>" + sMibile0 + "</div></div>";
						}
					}
					//node.innerHTML = "<span class=\"momile_cell\"><span class=\"momile_cell_span_table_left_first\">" + sMibile1 + "</span><span class=\"momile_cell_span_table_left_second\">" + sMibile2 + "</span></span>"
					dataViewBuffer.push(data[i]);
					if (bFrozen) {
						nodeFrozen["NewID"] = data[i][sKey];
						nodeFrozen["id"] = name + "_frozen_row_" + data[i][sKey];
					}
					lastNode = node;
					if (i == childs.length - 1) {
						//node.classList.add("borderBottom");
						if (bFrozen) {
							//nodeFrozen.classList.add("borderBottom");
						}
					}
					if (iClickIndex == data[i][sKey]) {
						node.click();
					} else if (Options["isMobile"]) {
						document.getElementById(node.id).classList.remove("mouseovercolor");
						document.getElementById(node.id).classList.remove("mouseclickcolor");
					}
					if (bTop) {
						bTop = false;
						sTopBorder = "";
					}
				}
			}
			ViewShow(name, dataViewBuffer);
			//console.log(dataViewBuffer);//实际显示数据
			return;
		}
	}

	function GetBufferKeyIndex() {
		var arrDataT = [];
		for (var i = 0; i < dataBuffer.length; i++) {
			arrDataT[dataBuffer[sKey]] = i;
		}
		arrBufferKeyIndex = arrDataT;
	}

	function value() {
		return this.dom.value;
	}

	function getData(index, key) {
		if (index != undefined) {
			if (index < dataBuffer.length) {
				return dataBuffer[index];
			}
		} else if (key != undefined) {
			for (var i = 0; i < dataBuffer.length; i++) {
				if (dataBuffer[i][sKey] == key) {
					return dataBuffer[i];
				}
			}
		} else {
			return dataBuffer;
		}
		return undefined;
	}

	function getIndex(key) {
		for (var i = 0; i < dataBuffer.length; i++) {
			if (dataBuffer[i][sKey] == key) {
				if (dataBuffer[i]["searchdisable"]) {
					return undefined;
				}
				return {
					index: i,
					row: dataBuffer[i]
				};
			}
		}
		/* for (var i = 0; i < arrDataInterVal.length; i++) {
		    if (arrDataInterVal[i].row[sKey] == key && !arrDataInterVal[i].isDel) {
		        return { index: dataBuffer.length + i, row: arrDataInterVal[i].row };
		    }
		} */
		return undefined;
	}

	var arrDataInterVal = [];
	var iFrameCount = 1;

	function UpdateInterval() {
		if (arrDataInterVal.length > 0 && iFrameCount > 50 && !bStartSearch) {
			try {
				iFrameCount = 1;
				var bUpdateHeigth = false;
				var iSrollIndex = -1;
				var bUpdateView = false;
				for (var k = 0; k < arrDataInterVal.length; k++) {
					var index = arrDataInterVal[k].index;
					var row = arrDataInterVal[k].row;
					if (index == undefined) {
						//插在最后
						var bExists = false;
						if (arrDataInterVal[k].isDel) {
							bExists = true;
						}
						for (var i = 0; i < dataBuffer.length; i++) {
							if (dataBuffer[i][sKey] == row[sKey]) {
								bExists = true;
								var bUpdate = true;
								var bSearchdisableTT = false;
								for (var rowCT in row) {
									dataBuffer[i][rowCT] = row[rowCT];
								}
								if (bSearchData) {
									for (var j = 0; j < arrHeader.length; j++) {
										if (arrHeader[j].search && arrHeader[j].searchText && arrHeader[j].searchText.length > 0) {
											if (arrHeader[j]["formatter"](dataBuffer[i], dataBuffer[i][arrHeader[j].field]).toUpperCase().indexOf(
													arrHeader[j].searchText) == -1) {
												bSearchdisableTT = true;
												break;
											}
										}
									}
									if (!bSearchdisableTT && Options["searchEvt"]) {
										if (!Options["searchEvt"](dataBuffer[i])) {
											bSearchdisableTT = true;
										}
									}
								}
								if (dataBuffer[i]["searchdisable"] != bSearchdisableTT) {
									bUpdateHeigth = true;
								}
								dataBuffer[i]["searchdisable"] = bSearchdisableTT;
								if (arrDataInterVal[k].isDel) {
									bUpdateHeigth = true;
									dataBuffer.splice(i, 1);
									break;
								}
								/* for (var j = 0; j < dataViewBuffer.length; j++) {
                                    if (dataViewBuffer[j][sKey] == row[sKey]) {
                                        bUpdate = true;
                                        bUpdateView = true;
										if(arrDataInterVal[k].searchdisable){
											dataViewBuffer[j]["searchdisable"] = true;
											bUpdateHeigth = true;
										}
                                        break;
                                    }
                                } */
								if (bUpdate && !bUpdateHeigth) {
									for (var j = 0; j < arrHeader.length; j++) {
										if (row[arrHeader[j].field] != undefined) {
											dataBuffer[i][arrHeader[j].field] = row[arrHeader[j].field];

											try {
												var domTemp = document.getElementById(name + "_row" + row[sKey] + "_coln" + j);
												if (domTemp != undefined) {
													domTemp.innerHTML = arrHeader[j].formatter(row, row[arrHeader[j].field]);
												}
												if (arrHeader[j].frozen) {
													domTemp = document.getElementById(name + "_frozen_row" + row[sKey] + "_coln" + j);
													if (domTemp != undefined) {
														domTemp.innerHTML = arrHeader[j].formatter(row, row[arrHeader[j].field]);
													}
												}
											} catch (e) {
												console.log("更新Row行界面出错：" + e.message);
											}
										}
									}
								}
								break;
							}
						}
						if (!bExists) {
							var bSearchdisableTT = false;
							if (bSearchData) {
								for (var j = 0; j < arrHeader.length; j++) {
									if (arrHeader[j].search && arrHeader[j].searchText && arrHeader[j].searchText.length > 0) {
										if (arrHeader[j]["formatter"](row, row[arrHeader[j].field]).toUpperCase().indexOf(arrHeader[j].searchText) ==
											-1) {
											bSearchdisableTT = true;
											break;
										}
									}
								}
								if (!bSearchdisableTT && Options["searchEvt"]) {
									if (!Options["searchEvt"](dataBuffer[i])) {
										bSearchdisableTT = true;
									}
								}
							}
							row["searchdisable"] = bSearchdisableTT;
							dataBuffer.push(row);
							bUpdateHeigth = true;
						}
					} else {
						//插在指定位置
						var bExists = false;
						for (var i = 0; i < dataBuffer.length; i++) {
							if (dataBuffer[i][sKey] == row[sKey]) {
								bExists = true;
								for (var rowCT in row) {
									dataBuffer[i][rowCT] = row[rowCT];
								}
								row = dataBuffer[i];
								dataBuffer.splice(i, 1);
								break;
							}
						}
						var bSearchdisableTT = false;
						if (bSearchData) {
							for (var j = 0; j < arrHeader.length; j++) {
								if (arrHeader[j].search && arrHeader[j].searchText && arrHeader[j].searchText.length > 0) {
									if (arrHeader[j]["formatter"](row, row[arrHeader[j].field]).toUpperCase().indexOf(arrHeader[j].searchText) ==
										-1) {
										bSearchdisableTT = true;
										break;
									}
								}
							}
							if (!bSearchdisableTT && Options["searchEvt"]) {
								if (!Options["searchEvt"](dataBuffer[i])) {
									bSearchdisableTT = true;
								}
							}
						}
						row["searchdisable"] = bSearchdisableTT;
						dataBuffer.splice(index, 0, row);
						if (!bExists) {
							//updateHeight();
							bUpdateHeigth = true;
						}
						if (index && index != 1) {
							iSrollIndex = index;
						}
						//scrollToIndex(index);
					}
				}
				for (var i = 0; i < dataBuffer.length; i++) {
					dataBuffer[i][name + "_sn"] = dataBuffer.length - i;
				}
				$.each(arrMergeWait, function(iM, valueM) {
					if (valueM.isMerge) {
						//合并单元格
						$.each(valueM.arrMerge, function(jM, valueJ) {
							if (valueJ.r == 0) {
								return true;
							} else if (valueJ.r == 1) {
								if (!dataBuffer[valueM.index]["arrMerge"]) {
									dataBuffer[valueM.index]["arrMerge"] = [];
								}
								dataBuffer[valueM.index]["arrMerge"].push({
									"sn": 2,
									"b": true,
									"c": valueJ
								}); //结束
							} else {
								for (var k = 0; k < valueJ.r; k++) {
									if (k == 0) {
										if (!dataBuffer[valueM.index + k]["arrMerge"]) {
											dataBuffer[valueM.index + k]["arrMerge"] = [];
										}
										dataBuffer[valueM.index + k]["arrMerge"].push({
											"sn": 0,
											"b": false,
											"c": valueJ
										}); //开始
									} else if (k == valueJ.r - 1) {
										if (!dataBuffer[valueM.index + k]["arrMerge"]) {
											dataBuffer[valueM.index + k]["arrMerge"] = [];
										}
										dataBuffer[valueM.index + k]["arrMerge"].push({
											"sn": 2,
											"b": true,
											"c": valueJ
										}); //中途
									} else {
										if (!dataBuffer[valueM.index + k]["arrMerge"]) {
											dataBuffer[valueM.index + k]["arrMerge"] = [];
										}
										dataBuffer[valueM.index + k]["arrMerge"].push({
											"sn": 1,
											"b": false,
											"c": valueJ
										}); //结束
									}
								}
							}
						});
					} else {
						$.each(valueM.arrMerge, function(jM, valueJ) {
							if (valueJ.r == 0) {
								return true;
							} else if (valueJ.r == 1) {
								if (dataBuffer[valueM.index]["arrMerge"]) {
									$.each(dataBuffer[valueM.index]["arrMerge"], function(d, valued) {
										if (valued.c.c == valueJ.c) {
											dataBuffer[valueM.index]["arrMerge"].splice(d, 1);
											return false;
										}
									});
								}
							} else {
								for (var k = 0; k < valueJ.r; k++) {
									if (dataBuffer[valueM.index + k]["arrMerge"]) {
										$.each(dataBuffer[valueM.index + k]["arrMerge"], function(d, valued) {
											if (valued.c.c == valueJ.c) {
												dataBuffer[valueM.index + k]["arrMerge"].splice(d, 1);
												return false;
											}
										});
									}
								}
							}
						});
					}
				});
				if (bUpdateHeigth || iSrollIndex != -1 || arrMergeWait.length > 0) {
					bGlobalSetData = false;
				} else {
					bGlobalSetData = true;
				}
				if (bUpdateHeigth) {
					updateHeight();
				}
				if (iSrollIndex != -1 || arrMergeWait.length > 0) {
					bGlobalSetData = false;
					UpdateRowView();
					bGlobalSetData = true;
					scrollToIndex(iSrollIndex);
				}
				arrMergeWait = [];
				if (!bUpdateHeigth && iSrollIndex == -1 && bUpdateView) {
					ViewShow(name, dataViewBuffer);
				}
			} catch (e) {
				console.log("更新失败：" + e.message);
			}
			arrDataInterVal = [];
			iSearchdisableCount = 0;
			arrShowTrue = [];
			$.each(dataBuffer, function(i, value) {
				if (value["searchdisable"]) {
					iSearchdisableCount++;
				} else {
					arrShowTrue.push(value);
				}
			});
		} else {
			if (arrMergeWait.length > 0) {
				$.each(arrMergeWait, function(iM, valueM) {
					if (valueM.isMerge) {
						//合并单元格
						$.each(valueM.arrMerge, function(jM, valueJ) {
							if (valueJ.r == 0) {
								return true;
							} else if (valueJ.r == 1) {
								if (!dataBuffer[valueM.index]["arrMerge"]) {
									dataBuffer[valueM.index]["arrMerge"] = [];
								}
								dataBuffer[valueM.index]["arrMerge"].push({
									"sn": 2,
									"b": true,
									"c": valueJ
								}); //结束
							} else {
								for (var k = 0; k < valueJ.r; k++) {
									if (k == 0) {
										if (!dataBuffer[valueM.index + k]["arrMerge"]) {
											dataBuffer[valueM.index + k]["arrMerge"] = [];
										}
										dataBuffer[valueM.index + k]["arrMerge"].push({
											"sn": 0,
											"b": false,
											"c": valueJ
										}); //开始
									} else if (k == valueJ.r - 1) {
										if (!dataBuffer[valueM.index + k]["arrMerge"]) {
											dataBuffer[valueM.index + k]["arrMerge"] = [];
										}
										dataBuffer[valueM.index + k]["arrMerge"].push({
											"sn": 2,
											"b": true,
											"c": valueJ
										}); //中途
									} else {
										if (!dataBuffer[valueM.index + k]["arrMerge"]) {
											dataBuffer[valueM.index + k]["arrMerge"] = [];
										}
										dataBuffer[valueM.index + k]["arrMerge"].push({
											"sn": 1,
											"b": false,
											"c": valueJ
										}); //结束
									}
								}
							}
						});
					} else {
						$.each(valueM.arrMerge, function(jM, valueJ) {
							if (valueJ.r == 0) {
								return true;
							} else if (valueJ.r == 1) {
								if (dataBuffer[valueM.index]["arrMerge"]) {
									$.each(dataBuffer[valueM.index]["arrMerge"], function(d, valued) {
										if (valued.c.c == valueJ.c) {
											dataBuffer[valueM.index]["arrMerge"].splice(d, 1);
											return false;
										}
									});
								}
							} else {
								for (var k = 0; k < valueJ.r; k++) {
									if (dataBuffer[valueM.index + k]["arrMerge"]) {
										$.each(dataBuffer[valueM.index + k]["arrMerge"], function(d, valued) {
											if (valued.c.c == valueJ.c) {
												dataBuffer[valueM.index + k]["arrMerge"].splice(d, 1);
												return false;
											}
										});
									}
								}
							}
						});
					}
				});
				arrMergeWait = [];
				UpdateRowView();
				console.log(dataBuffer);
			}
		}

		requestAnimationFrame(function() {
			iFrameCount = iFrameCount + 1;
			UpdateInterval();
		});
	}
	requestAnimationFrame(function() {
		iFrameCount = iFrameCount + 1;
		UpdateInterval();
	});
	//    setInterval(function() { UpdateInterval(); }, 1000);

	var timeoutViewShow = undefined;

	function ViewShow(nameT, dataViewBufferT) {
		if (timeoutViewShow != undefined) {
			clearTimeout(timeoutViewShow);
		}
		if (Options != undefined && Options["viewshow"] != undefined) {
			timeoutViewShow = setTimeout(function() {
				timeoutViewShow = undefined;
				Options["viewshow"](nameT, dataViewBufferT);
			}, 500);
		}
	}

	function setRow(row, index) {
		var bSearchdisable = false;
		arrDataInterVal.push({
			row: row,
			index: index,
			isDel: false,
			searchdisable: bSearchdisable
		});
		if (arrDataInterVal.length > 30000) {
			iFrameCount = 100;
			UpdateInterval();
		}
	}

	function delRow(row) {
		arrDataInterVal.push({
			row: row,
			index: undefined,
			isDel: true
		});
	}

	function updateHeight() {
		//        scrolltable.SelectByID('BufferContainer').height(scrolltable.dom.offsetHeight - rowHeight - 20);
		scrolltable.SelectByID('BufferContainer').height(scrolltable.dom.offsetHeight - rowHeight);
		if (Options["hideHeader"]) {
			scrolltable.SelectByID('BufferContainer').height(scrolltable.dom.offsetHeight);
		}
		if (bFrozen) {
			scrolltable.SelectByID('Frozen_BufferContainer').height(scrolltable.dom.offsetHeight - rowHeight);
			if (Options["hideHeader"]) {
				scrolltable.SelectByID('Frozen_BufferContainer').height(scrolltable.dom.offsetHeight);
			}
		}
		document.getElementById(name + '_Scroller').style.width = (document.getElementById(name).offsetWidth) + 'px';
		VIEW_HEIGHT = scrolltable.SelectByID('BufferContainer').height(); //更新后的Buffer大小
		divBufferView = scrolltable.SelectByID('BufferView').height(scrolltable.nearestModulo(VIEW_HEIGHT, rowHeight) +
			PREBUFFER_HEIGHT * 2 + 1);
		if (bFrozen && divFrozenBufferView != undefined) {
			divFrozenBufferView = scrolltable.SelectByID('Frozen_BufferView').height(scrolltable.nearestModulo(VIEW_HEIGHT,
					rowHeight) +
				PREBUFFER_HEIGHT * 2 + 1);
		}
		var iMaxWidth = scrolltable.dom.offsetWidth;
		var iSrollWidth = 0;
		for (var i = 0; i < arrHeader.length; i++) {
			if (arrHeader[i]["hide"]) {
				continue;
			}
			iSrollWidth += arrHeader[i].width;
		}
		if (iSrollWidth > iMaxWidth) {
			iMaxWidth = iSrollWidth;
		}
		document.getElementById(name + '_BufferView').style.width = (iMaxWidth) + 'px';
		if (Options["isMobile"]) {
			document.getElementById(name + '_BufferView').style.width = "100%";
		}
		//document.getElementById(name + '_BufferAllView').style.width = document.getElementById(name + '_BufferActualDomain').offsetWidth + 'px';
		document.getElementById(name + '_BufferAllView').style.width = document.getElementById(name).offsetWidth + 'px';
		document.getElementById(name + '_Header').style.width = (iMaxWidth) + 'px';
		var arrSearchDataT = [];
		$.each(dataBuffer, function(i, value) {
			if (!value["searchdisable"]) {
				arrSearchDataT.push(value);
			}
		});
		var bufferLengthT = arrSearchDataT.length;
		var iPagingCountAll = Math.ceil(arrSearchDataT.length / (iPagingCount * 1.0));
		if (iPagingIndex > iPagingCountAll) {
			iPagingIndex = iPagingCountAll;
		} else if (iPagingIndex == 0) {
			iPagingIndex = 1;
		}
		if (arrSearchDataT.length <= iPagingCount) {
			ACTUALDOMAIN_HEIGHT = arrSearchDataT.length * rowHeight; //实际大小
		} else {
			bufferLengthT = arrSearchDataT.length - (iPagingCount * (iPagingIndex - 1));
			if (bufferLengthT > iPagingCount) {
				bufferLengthT = iPagingCount;
			}
			ACTUALDOMAIN_HEIGHT = bufferLengthT * rowHeight; //实际大小
		}
		if (iPagingCountAll != $("#" + name + "_pagedropdown")[0].options.length) {
			$("#" + name + "_pagedropdown")[0].options.length = 0;
			for (var iT = 1; iT <= iPagingCountAll; iT++) {
				$("#" + name + "_pagedropdown").append("<option value='" + iT + "'>" + iT + "</option>");
			}
			if (iPagingCountAll == 0) {
				$("#" + name + "_pagedropdown").append("<option value='1'>1</option>");
			}
		}
		//        if (ACTUALDOMAIN_HEIGHT <= VIEW_HEIGHT) {
		//            divBufferView = scrolltable.SelectByID('BufferView').height(VIEW_HEIGHT);
		//            if (bFrozen && divFrozenBufferView != undefined) {
		//                divFrozenBufferView = scrolltable.SelectByID('Frozen_BufferView').height(VIEW_HEIGHT);
		//            }
		//            ACTUALDOMAIN_HEIGHT = 0;
		//        } else if (ACTUALDOMAIN_HEIGHT <= VIEW_HEIGHT + PREBUFFER_HEIGHT_TWICE) {
		//            divBufferView = scrolltable.SelectByID('BufferView').height(ACTUALDOMAIN_HEIGHT);
		//            if (bFrozen && divFrozenBufferView != undefined) {
		//                divFrozenBufferView = scrolltable.SelectByID('Frozen_BufferView').height(ACTUALDOMAIN_HEIGHT);
		//            }
		//            ACTUALDOMAIN_HEIGHT = 0;
		//        }
		size = divBufferView.height() / rowHeight;
		//        scrolltable.SelectByID('BufferActualDomain').height(ACTUALDOMAIN_HEIGHT - divBufferView.height());
		scrolltable.SelectByID('BufferActualDomain').height(ACTUALDOMAIN_HEIGHT + rowHeight);
		var iActualCount = Math.ceil(bufferLengthT / 30000.0);
		for (var iAT = 0; iAT < arrBufferDomainActual.length; iAT++) {
			document.getElementById(name + "_BufferContainer").removeChild(arrBufferDomainActual[iAT]);
		}
		arrBufferDomainActual.length = 0;
		var iActualCountT = ACTUALDOMAIN_HEIGHT;
		for (var iAT = 0; iAT < iActualCount - 1; iAT++) {
			if (iAT == 0) {
				scrolltable.SelectByID('BufferActualDomain').height((30000 * rowHeight) + rowHeight);
				iActualCountT = iActualCountT - (30000 * rowHeight);
			}
			var eleChild = document.createElement('div');
			eleChild.classList.add("actual-domain");
			eleChild.id = name + "_BufferActualDomain" + iAT;
			if (iActualCountT > (30000 * rowHeight)) {
				eleChild.style.height = (30000 * rowHeight) + "px";
				iActualCountT = iActualCountT - (30000 * rowHeight);
			} else {
				eleChild.style.height = iActualCountT + "px";
				iActualCountT = 0;
			}
			document.getElementById(name + "_BufferContainer").appendChild(eleChild);
			arrBufferDomainActual.push(eleChild);
		}
		var offset = scrolltable.SelectByID('BufferContainer').offset();
		if (offset.top == undefined) {
			offset.top = scrolltable.SelectByID('BufferContainer').dom.scrollTop;

		}
		var bottom = ACTUALDOMAIN_HEIGHT - offset.top - VIEW_HEIGHT;
		var top = offset.top;
		//console.log("updateHeight" + offset.top);
		//if (offset.top <= (rowHeight / 2)) {
		//    top = offset.top;
		//}
		//else if (offset.top < PREBUFFER_HEIGHT && ((dataBuffer.length * rowHeight - offset.top >= VIEW_HEIGHT && dataBuffer.length * rowHeight - offset.top >= PREBUFFER_HEIGHT_TWICE) || dataBuffer.length * rowHeight < VIEW_HEIGHT)) {
		//    top = offset.top;
		//} else if (offset.top > ACTUALDOMAIN_HEIGHT - PREBUFFER_HEIGHT_TWICE) {
		//    if (ACTUALDOMAIN_HEIGHT == 0) {
		//        divBufferView.css({
		//            top: ACTUALDOMAIN_HEIGHT - (rowHeight / 2) //offset.top - PREBUFFER_HEIGHT_TWICE - (rowHeight / 2)
		//        });
		//        ScrollFrozen(offset.top, ACTUALDOMAIN_HEIGHT - (rowHeight / 2));
		//    }
		//    else {
		//        divBufferView.css({
		//            top: offset.top - PREBUFFER_HEIGHT_TWICE - (rowHeight / 2)
		//        });
		//        ScrollFrozen(offset.top, offset.top - PREBUFFER_HEIGHT_TWICE - (rowHeight / 2));
		//    }

		//    setData(dataBuffer.slice(-size));
		//    return;
		//} else {
		//    top = offset.top - PREBUFFER_HEIGHT;
		//}

		var domain = range((iPagingCount * (iPagingIndex - 1) * rowHeight) + top, (iPagingCount * (iPagingIndex - 1) *
			rowHeight) + top + VIEW_HEIGHT + PREBUFFER_HEIGHT_TWICE);
		divBufferView.appendUpdate('div', size);
		setData(arrSearchDataT.slice((iPagingIndex - 1) * iPagingCount, (iPagingIndex) * iPagingCount).slice(domain[0] - (
			iPagingIndex - 1) * iPagingCount, domain[1] + 1 - (iPagingIndex - 1) * iPagingCount), false);
		if (!Options["isMobile"]) {
			$('#' + name + '_BufferContainer').niceScroll({
				horizrailenabled: false
			}).resize();
		}
	}

	function ScrollFrozen(offsetTop, buffTop) {
		//console.log("ScrollFrozen top" + buffTop + "ac " + ACTUALDOMAIN_HEIGHT + "pr" + PREBUFFER_HEIGHT);
		if (bFrozen && divFrozenBufferView != undefined) {
			var iTop = offsetTop;
			//            if (offsetTop <= PREBUFFER_HEIGHT) {
			//                iTop = -offsetTop;
			//            }
			//            else if (offsetTop >= ACTUALDOMAIN_HEIGHT - PREBUFFER_HEIGHT_TWICE) {
			//                iTop = buffTop - offsetTop;
			//            }
			//            else {
			//                iTop = -PREBUFFER_HEIGHT;
			//            }
			//divFrozenBufferView.css({
			//    top: iTop
			//});
		}
	}

	function UpdateRowView() {
		var offset = scrolltable.SelectByID('BufferContainer').offset();
		if (offset.top == undefined) {
			offset.top = scrolltable.SelectByID('BufferContainer').dom.scrollTop;

		}
		//        var bottom = ACTUALDOMAIN_HEIGHT - offset.top - VIEW_HEIGHT;
		var top = offset.top;

		//        if (offset.top < PREBUFFER_HEIGHT) {
		//            top = -offset.top;
		//        } else if (offset.top > ACTUALDOMAIN_HEIGHT - PREBUFFER_HEIGHT_TWICE) {
		//            divBufferView.css({
		//                top: offset.top - PREBUFFER_HEIGHT_TWICE - (rowHeight / 2)
		//            });
		//            ScrollFrozen(offset.top, offset.top - PREBUFFER_HEIGHT_TWICE - (rowHeight / 2));
		//            setData(dataBuffer.slice(-size));
		//            return;
		//        } else {
		//            top = offset.top - PREBUFFER_HEIGHT;
		//        }


		//divBufferView.css({ top: top });
		//console.log("UpdateRowView" + top);
		var domain = range(((iPagingIndex - 1) * rowHeight * iPagingCount) + top, ((iPagingIndex - 1) * rowHeight *
			iPagingCount) + top + VIEW_HEIGHT + PREBUFFER_HEIGHT_TWICE);
		divBufferView.appendUpdate('div', size);
		var arrSearchDataT = [];
		$.each(dataBuffer, function(i, value) {
			if (!value["searchdisable"]) {
				arrSearchDataT.push(value);
			}
		});
		setData(arrSearchDataT.slice((iPagingIndex - 1) * iPagingCount, (iPagingIndex) * iPagingCount).slice(domain[0] - (
			iPagingIndex - 1) * iPagingCount, domain[1] + 1 - (iPagingIndex - 1) * iPagingCount), false);
	}

	function addEvent(xEvent, fn) {
		var obj = document.getElementById(name + '_BufferView');
		if (obj && obj.attachEvent) {
			obj.attachEvent('on' + xEvent, fn);
		} else if (obj) {
			obj.addEventListener(xEvent, fn, false);
		}
		obj = document.getElementById(name + '_Frozen_BufferView');
		if (obj && obj.attachEvent) {
			obj.attachEvent('on' + xEvent, fn);
		} else if (obj) {
			obj.addEventListener(xEvent, fn, false);
		}
	}

	function addMobileEvent(divName) {
		/* var xy=document.getElementById("movedX");
		var endxy=document.getElementById("clientX");
		var content=document.getElementById("evtName"); */
		var xStart = 0;
		var yStart = 0;
		var x, y, end_x, end_y;
		var iTouchCount = 0;
		var bTouchMove = false;
		document.getElementById(divName).addEventListener("touchstart", function(evt) {
			bTouchMove = false;
			//evt.preventDefault();
			var touch = evt.touches[0];
			x = parseInt(touch.pageX),
				y = parseInt(touch.pageY);
			end_x = x,
				end_y = y;
			//xy.innerHTML=x+","+y;
			xStart = end_x;
			yStart = end_y;
			//content.innerHTML="";	
			iTouchCount = 0;
			$('#' + name + "_BufferTouchView").hide();
			$('#' + name + "_BufferContainer")[0].style.zIndex = 666;
			setTimeout(function() {
				$('#' + name + "_BufferTouchView").show();
				$('#' + name + "_BufferContainer").show();
				$('#' + name + "_BufferContainer")[0].style.zIndex = 999;
			}, 350);
		}, false);
		document.getElementById(divName).addEventListener("touchmove", function(evt) {
			//evt.preventDefault();
			var touch = evt.touches[0];
			end_x = parseInt(touch.pageX),
				end_y = parseInt(touch.pageY);
			//xy.innerHTML=end_x+","+end_y;
			var top = getWheelScrollTop();
			//滚动时对滚动条距顶的数量进行加一项高度或减一项高度达到控制滚动条的目的
			if (end_y > yStart + 15) {
				onMouseOverBuffer();
				bTouchMove = true;
				iTouchCount = iTouchCount - (end_y - yStart);
				yStart = end_y;
				//$('#' + name + "_BufferTouchView").show();
				//  if(divName == (name + "_BufferTouchView")){
				// iTouchCount = 0;
				//  }
				iTouchCount = 0;
				$("#" + name + "_BufferContainer").scrollTop(top - rowHeight);
				//content.innerHTML="我上了";
			} else if (end_y < yStart - 15) {
				onMouseOverBuffer();
				bTouchMove = true;
				iTouchCount = iTouchCount + (yStart - end_y);
				yStart = end_y;
				//$('#' + name + "_BufferTouchView").show();
				/* if(divName == (name + "_BufferTouchView")){
					iTouchCount = 0;
					$('#divlog').html("_BufferContainer" + (top + rowHeight));
			   } */
				iTouchCount = 0;
				$("#" + name + "_BufferContainer").scrollTop(top + rowHeight);
				//content.innerHTML="我下了";
			}
			if (end_x > xStart + 15) {
				/* e.preventDefault();
				e.stopPropagation(); */
				xStart = end_x;
				var iLeftT = document.getElementById(name).offsetLeft;
				var iWidthT = document.getElementById(name).offsetWidth;
				var iLeftBufT = document.getElementById(name + '_BufferView').offsetLeft;
				var iWidthBufT = document.getElementById(name + '_BufferView').offsetWidth;
				$('#divlog').html("向右" + iLeftT + "," + iLeftBufT + "," + iWidthT + "," + iWidthBufT);
				if ((iLeftT - iLeftBufT) > 0) {
					var iMoveT = iLeftT - iLeftBufT;
					if (iMoveT > 10) {
						iMoveT = 10;
					}
					$('#divlog').html("向右" + iLeftT + "," + iLeftBufT + "," + iWidthT + "," + iWidthBufT + "," + iMoveT);
					document.getElementById(name + "_BufferView").style.left = (iLeftBufT + iMoveT) + 'px';
				}
				//$("#" + name + "_Scroller").scrollLeft(getLeftScrollLeft() - 10);
				//content.innerHTML="我右了";
			} else if (end_x < xStart - 15) {
				/* e.preventDefault();
				e.stopPropagation(); */
				xStart = end_x;
				var iLeftT = document.getElementById(name).offsetLeft;
				var iWidthT = document.getElementById(name).offsetWidth;
				var iLeftBufT = document.getElementById(name + '_BufferView').offsetLeft;
				var iWidthBufT = document.getElementById(name + '_BufferView').offsetWidth;
				$('#divlog').html("向左" + iLeftT + "," + iLeftBufT + "," + iWidthT + "," + iWidthBufT);
				if ((iLeftT - iLeftBufT) + iWidthT < iWidthBufT) {
					var iMoveT = iWidthBufT - iWidthT - (iLeftT - iLeftBufT);
					if (iMoveT > 10) {
						iMoveT = 10;
					}
					$('#divlog').html("向左" + iLeftT + "," + iLeftBufT + "," + iWidthT + "," + iWidthBufT + "," + iMoveT);
					document.getElementById(name + "_BufferView").style.left = (iLeftBufT - iMoveT) + 'px';

				}
				//$("#" + name + "_Scroller").scrollLeft(getLeftScrollLeft() + 10);
				//content.innerHTML="我左了";
			}
		}, false)
		document.getElementById(divName).addEventListener("touchend", function(evt) {
			bTouchMove = false;
			var x_x = end_x - x;
			var y_y = end_y - y;
			//$('#' + name + "_BufferTouchView").hide();
			//endxy.innerHTML=x_x+","+y_y;
			//document.title="x轴移动了"+x_x+" ,y轴移动了"+y_y;
			/* if(y_y<-50){
			  content.innerHTML="由于你向上滑动了一段距离，所以我要插入内容了";
		   }else{
			  content.innerHTML="";
		   } */
			xStart = 0;
			yStart = 0;
			if (iTouchCount != 0) {
				var top = getWheelScrollTop();
				$("#" + name + "_BufferContainer").scrollTop(top + parseInt((rowHeight * (iTouchCount / rowHeight))));
			}
			/* if (iTouchCount < 0) {
				$("#" + name + "_BufferContainer").scrollTop(top - rowHeight);
		   } else if(end_y < yStart) {
				$("#" + name + "_BufferContainer").scrollTop(top + rowHeight);
		   } */
			iTouchCount = 0;
		}, false)
	}

	function addEventSroll(xEvent, fn) {
		var obj = document.getElementById(name + '_tablefooter');
		if (obj.attachEvent) {
			obj.attachEvent('on' + xEvent, fn);
		} else {
			obj.addEventListener(xEvent, fn, false);
		}
		obj = document.getElementById(name + '_pagedropdown');
		if (obj.attachEvent) {
			obj.attachEvent('on' + xEvent, fn);
		} else {
			obj.addEventListener(xEvent, fn, false);
		}
	}

	//获取滚动条距顶部的数值
	function getWheelScrollTop() {
		var scrollTop = $("#" + name + "_BufferContainer").prop('scrollTop');
		//console.log(scrollTop);
		return scrollTop;
	}


	//获取滚动条距左边的数值
	function getLeftScrollLeft() {
		var scrollLeft = $("#" + name + "_Scroller").prop('scrollLeft');
		return scrollLeft;
	}

	//列表区域的滚轮事件绑定
	function onMouseWheel(ev) {
		var ev = ev || window.event;
		var down = true;
		down = ev.wheelDelta ? ev.wheelDelta < 0 : ev.detail > 0;
		var top = getWheelScrollTop();
		//滚动时对滚动条距顶的数量进行加一项高度或减一项高度达到控制滚动条的目的
		if (down) {
			$("#" + name + "_BufferContainer").scrollTop(top + rowHeight);
		} else {
			$("#" + name + "_BufferContainer").scrollTop(top - rowHeight);
		}
		if (ev.preventDefault) {
			ev.preventDefault();
		}
		return false;
	}

	function onMouseOverBuffer() {
		//$("#" + name + "_ScrollerWidth").show();
		if (dataBuffer.length - iSearchdisableCount > iPagingCount) {
			$("#" + name + "_tablefooter").show();
		} else {
			$("#" + name + "_tablefooter").hide();
		}
	}

	function onMouseOutBuffer() {
		//$("#" + name + "_ScrollerWidth").hide();
		if (!document.getElementById(name + '_pagedropdown').bypass) {
			$("#" + name + "_tablefooter").hide();
		}
	}

	var sKey = "";
	var divFrozenBufferView = undefined;
	createHeader();
	createBuffer();
	addEvent('mousewheel', onMouseWheel);
	addEvent('mouseover', onMouseOverBuffer);
	addEvent('mouseout', onMouseOutBuffer);
	addEventSroll('mouseover', onMouseOverBuffer);
	addEventSroll('mouseout', onMouseOutBuffer);
	addEvent('DOMMouseScroll', onMouseWheel);
	//addMobileEvent(name + "_BufferAllView");
	if (Options["isMobile"]) {
		addMobileEvent(name + "_BufferTouchView");
		//$('#' + name + "_BufferTouchView").hide();
	}
	var objpagedropdown = document.getElementById(name + '_pagedropdown');
	if (objpagedropdown.attachEvent) {
		objpagedropdown.attachEvent('onclick', function() {
			objpagedropdown.bypass = true;
		});
	} else {
		objpagedropdown.addEventListener('click', function() {
			objpagedropdown.bypass = true;
		}, false);
	}
	//生成表格	
	var PREBUFFER_HEIGHT = PREBUFFER * rowHeight; //  前后预缓存元素高度
	var PREBUFFER_HEIGHT_TWICE = PREBUFFER_HEIGHT * 2; // 前后预缓存之和高度
	var VIEW_HEIGHT = scrolltable.SelectByID('BufferContainer').height(); // 可视区视图高度
	var divBufferView = scrolltable.SelectByID('BufferView').height(scrolltable.nearestModulo(VIEW_HEIGHT, rowHeight) +
		PREBUFFER_HEIGHT * 2 + 1);
	if (bFrozen && divFrozenBufferView != undefined) {
		divFrozenBufferView = scrolltable.SelectByID('Frozen_BufferView').height(scrolltable.nearestModulo(VIEW_HEIGHT,
				rowHeight) +
			PREBUFFER_HEIGHT * 2 + 1);
	}

	var ACTUALDOMAIN_HEIGHT = dataBuffer.length * rowHeight; // 实际计算区域高度
	//    if (ACTUALDOMAIN_HEIGHT <= VIEW_HEIGHT) {
	//        divBufferView = scrolltable.SelectByID('BufferView').height(VIEW_HEIGHT);
	//        if (bFrozen && divFrozenBufferView != undefined) {
	//            divFrozenBufferView = scrolltable.SelectByID('Frozen_BufferView').height(VIEW_HEIGHT);
	//        }
	//        ACTUALDOMAIN_HEIGHT = 0;
	//    } else if (ACTUALDOMAIN_HEIGHT <= VIEW_HEIGHT + PREBUFFER_HEIGHT_TWICE) {
	//        divBufferView = scrolltable.SelectByID('BufferView').height(ACTUALDOMAIN_HEIGHT);
	//        if (bFrozen && divFrozenBufferView != undefined) {
	//            divFrozenBufferView = scrolltable.SelectByID('Frozen_BufferView').height(ACTUALDOMAIN_HEIGHT);
	//        }
	//        ACTUALDOMAIN_HEIGHT = 0;
	//    }
	var size = divBufferView.height() / rowHeight;
	var vsize = Math.ceil(VIEW_HEIGHT / rowHeight);
	scrolltable.SelectByID('BufferActualDomain').height(ACTUALDOMAIN_HEIGHT + rowHeight);
	var iActualCount = Math.ceil(dataBuffer.length / 30000.0);
	for (var iAT = 0; iAT < arrBufferDomainActual.length; iAT++) {
		document.getElementById(name + "_BufferContainer").removeChild(arrBufferDomainActual[iAT]);
	}
	arrBufferDomainActual.length = 0;
	var iActualCountT = ACTUALDOMAIN_HEIGHT;
	for (var iAT = 0; iAT < iActualCount - 1; iAT++) {
		if (iAT == 0) {
			scrolltable.SelectByID('BufferActualDomain').height((30000 * rowHeight) + rowHeight);
			iActualCountT = iActualCountT - (30000 * rowHeight);
		}
		var eleChild = document.createElement('div');
		eleChild.classList.add("actual-domain");
		eleChild.id = name + "_BufferActualDomain" + iAT;
		if (iActualCountT > (30000 * rowHeight)) {
			eleChild.style.height = (30000 * rowHeight) + "px";
			iActualCountT = iActualCountT - (30000 * rowHeight);
		} else {
			eleChild.style.height = iActualCountT + "px";
			iActualCountT = 0;
		}
		document.getElementById(name + "_BufferContainer").appendChild(eleChild);
		arrBufferDomainActual.push(eleChild);
	}
	scrolltable.SelectByID('BufferContainer').on('scroll', function(evt, obj) {
		var offset = scrolltable.SelectByID('BufferContainer').offset();
		if (offset.top == undefined) {
			offset.top = scrolltable.SelectByID('BufferContainer').dom.scrollTop;

		}
		//console.log("BufferContainer.scroll: " + offset.top);
		//console.log("offset origin: " + offset.top + "height " + ACTUALDOMAIN_HEIGHT);

		//        if (offset.top > ACTUALDOMAIN_HEIGHT && ACTUALDOMAIN_HEIGHT != 0) {
		//            //offset.top = ACTUALDOMAIN_HEIGHT;
		//            scrolltable.SelectByID('BufferContainer').dom.scrollTop = ACTUALDOMAIN_HEIGHT;
		//            if (bFrozen) {
		//                scrolltable.SelectByID('Frozen_BufferContainer').dom.scrollTop = ACTUALDOMAIN_HEIGHT;
		//            }
		//            //                bScrollMouseUp = false;
		//            return;
		//        }
		//        var bottom = ACTUALDOMAIN_HEIGHT - offset.top - VIEW_HEIGHT;
		var top = offset.top;

		//        if (offset.top >= ACTUALDOMAIN_HEIGHT - 15) {
		//            top = offset.top - PREBUFFER_HEIGHT_TWICE - 15;
		//        } else if (offset.top >= ACTUALDOMAIN_HEIGHT - VIEW_HEIGHT) {
		//            divBufferView.css({
		//                top: offset.top - PREBUFFER_HEIGHT_TWICE - (rowHeight / 2)
		//            });
		//            ScrollFrozen(offset.top, offset.top - PREBUFFER_HEIGHT_TWICE - (rowHeight / 2));
		//            setData(dataBuffer.slice(-size));
		//            //console.log("last " + offset.top + "hei " + ACTUALDOMAIN_HEIGHT + " view" + VIEW_HEIGHT);
		//            return;
		//        } else if (offset.top < PREBUFFER_HEIGHT) {
		//            //top = -offset.top;
		//        } else if (bottom < 0) {
		//            top = offset.top - PREBUFFER_HEIGHT;
		//            var rowDataTemp = dataBuffer.slice(top / rowHeight, top / rowHeight + size);

		//            if (rowDataTemp.length < vsize + PREBUFFER) {
		//                rowDataTemp = dataBuffer.slice(-(vsize + PREBUFFER));
		//                if (!bScrollMouseUp) {
		//                    if (dataBuffer.length < 50) {
		//                        scrolltable.SelectByID('BufferContainer').dom.scrollTop = ACTUALDOMAIN_HEIGHT - 15;
		//                    } else {
		//                        scrolltable.SelectByID('BufferContainer').dom.scrollTop = ACTUALDOMAIN_HEIGHT; // -VIEW_HEIGHT;
		//                    }
		//                    //console.log("up");
		//                    return;
		//                }
		//            }
		//            divBufferView.css({
		//                top: top
		//            });
		//            ScrollFrozen(offset.top, top);
		//            setData(rowDataTemp);
		//            return;
		//        } else {
		//            top = offset.top - PREBUFFER_HEIGHT;
		//        }
		//        if (ACTUALDOMAIN_HEIGHT <= VIEW_HEIGHT) {
		//            top = 0;
		//        }
		//        divBufferView.css({
		//            top: top
		//        });
		ScrollFrozen(offset.top, top);
		var arrSearchDataT = [];
		$.each(dataBuffer, function(i, value) {
			if (!value["searchdisable"]) {
				arrSearchDataT.push(value);
			}
		});
		setData(arrSearchDataT.slice(((iPagingIndex - 1) * iPagingCount * rowHeight + top) / rowHeight, ((iPagingIndex - 1) *
			iPagingCount * rowHeight + top) / rowHeight + size));
		//        if (offset.top < PREBUFFER_HEIGHT) {
		//            setData(dataBuffer.slice(0, size));
		//        } else if (offset.top >= PREBUFFER_HEIGHT && offset.top < PREBUFFER_HEIGHT_TWICE) {
		//            setData(dataBuffer.slice(top / rowHeight, top / rowHeight + size));
		//        } else if (offset.top + VIEW_HEIGHT <= ACTUALDOMAIN_HEIGHT) {
		//            setData(dataBuffer.slice(top / rowHeight, top / rowHeight + size));
		//        } else {
		//            setData(dataBuffer.slice(-size));
		//        }
	});

	function scrollToIndex(index) {
		//bScrollMouseUp = false;
		var arrSearchDataT = [];
		var iNewIndex = index;
		$.each(dataBuffer, function(i, value) {
			if (!value["searchdisable"]) {
				arrSearchDataT.push(value);
				if (index == (i + 1)) {
					iNewIndex = arrSearchDataT.length;
				}
			}
		});
		index = iNewIndex;
		if (index > arrSearchDataT.length - 1) {
			index = arrSearchDataT.length;
		}
		var iPagintIndexT = iPagingIndex;
		if (index > iPagingCount) {
			iPagingIndex = Math.ceil(index / (iPagingCount * 1.0));
			if (iPagingIndex == 0) {
				iPagingIndex = 1;
			}
		} else {
			iPagingIndex = 1;
		}
		index = index - 1;
		var iTop = index * rowHeight - ((iPagingIndex - 1) * rowHeight * iPagingCount);
		scrolltable.SelectByID('BufferContainer').dom.scrollTop = iTop;
		if (iPagintIndexT != iPagingIndex) {
			updateHeight();
		}
		if (iPagingIndex != parseInt($("#" + name + "_pagedropdown")[0].value)) {
			$("#" + name + "_pagedropdown").val(iPagingIndex);
		}
		UpdateRowView();

		//        if (dataBuffer.length - 1 <= index && ACTUALDOMAIN_HEIGHT != 0) {
		//            scrolltable.SelectByID('BufferContainer').dom.scrollTop = ACTUALDOMAIN_HEIGHT;
		//        } else if (dataBuffer.length - vsize <= index && ACTUALDOMAIN_HEIGHT != 0) {
		//            scrolltable.SelectByID('BufferContainer').dom.scrollTop = (dataBuffer.length - vsize) * rowHeight;
		//        } else if (index > PREBUFFER) {
		//            scrolltable.SelectByID('BufferContainer').dom.scrollTop = iTop;
		//        } else {
		//            scrolltable.SelectByID('BufferContainer').dom.scrollTop = iTop;
		//        }
	}

	function range(start, end) {
		return [
			scrolltable.nearestModulo(start, rowHeight) / rowHeight,
			scrolltable.nearestModulo(end, rowHeight) / rowHeight
		];
	}

	function SetSearch(funcSearch, onlyOne) {
		bStartSearch = true;
		try {
			Options["searchEvt"] = funcSearch;
			if (funcSearch == undefined) {
				bSearchData = false;
				for (var i = 0; i < arrHeader.length; i++) {
					if (arrHeader[i].search) {
						var sText = $('#' + name + "_search_" + arrHeader[i].field).val();
						if (sText.length > 0) {
							bSearchData = true;
							break;
						}
					}
				}
			} else {
				bSearchData = true;
			}
			Search(false);
			if (onlyOne) {
				Options["searchEvt"] = undefined;
			}
		} catch (e) {
			console.log(e);
		}
		bStartSearch = false;
	}

	function Search(bBtn) {
		arrSearchData = [];
		bSearchData = false;
		if (Options["searchEvt"]) {
			bSearchData = true;
		}
		var bSearchHeader = false;
		for (var i = 0; i < arrHeader.length; i++) {
			if (arrHeader[i].search) {
				if (bBtn) {
					var sText = $.trim($('#' + name + "_search_" + arrHeader[i].field).val());
					if (sText.length > 0) {
						bSearchData = true;
						bSearchHeader = true;
					}
					arrHeader[i].searchText = sText.toUpperCase();
				} else if (arrHeader[i].searchText && arrHeader[i].searchText.length > 0) {
					bSearchData = true;
					bSearchHeader = true;
					break;
				}
			} else {
				arrHeader[i].searchText = "";
			}
		}
		if (bSearchData) {
			$.each(dataBuffer, function(i, value) {
				value["searchdisable"] = false;
				if (bSearchHeader) {
					for (var j = 0; j < arrHeader.length; j++) {
						if (arrHeader[j].search && arrHeader[j].searchText && arrHeader[j].searchText.length > 0) {
							if (arrHeader[j]["formatter"](value, value[arrHeader[j].field]).toUpperCase().indexOf(arrHeader[j].searchText.toUpperCase()) ==
								-1) {
								value["searchdisable"] = true;
								break;
							}
						}
					}
				}
				if (!value["searchdisable"] && Options["searchEvt"]) {
					if (!Options["searchEvt"](value)) {
						value["searchdisable"] = true;
					}
				}
			});
		} else {
			$.each(dataBuffer, function(i, value) {
				value["searchdisable"] = false;
			});
			iniData(dataBuffer);
		}
		scrollToIndex(1);
		var arrSearchDataT = [];
		$.each(dataBuffer, function(i, value) {
			if (!value["searchdisable"]) {
				arrSearchDataT.push(value);
				if (arrSearchDataT.length == size) {
					return false;
				}
			}
		});
		setData(arrSearchDataT.slice(0, size), true);
	}
	divBufferView.append('div', size);
	setData(dataBuffer.slice(0, size));
	return scrolltable;
}

/* function getScrollbarWidth() {
    var odiv = document.createElement('div'), //创建一个div
        styles = {
            width: '100px',
            height: '100px',
            overflowY: 'scroll'//让他有滚动条
        }, i, scrollbarWidth;
    for (i in styles) odiv.style[i] = styles[i];
    document.body.appendChild(odiv); //把div添加到body中
    scrollbarWidth = odiv.offsetWidth - odiv.clientWidth; //相减
    //    odiv.remove(); //移除创建的div
    document.body.removeChild(odiv);
    return scrollbarWidth; //返回滚动条宽度
} */
